From patchwork Tue Aug 18 07:34:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 11720177 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E989138C for ; Tue, 18 Aug 2020 07:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 512732076E for ; Tue, 18 Aug 2020 07:34:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aliNNij2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726391AbgHRHeV (ORCPT ); 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 ); 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 ; Tue, 18 Aug 2020 00:34:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p138so21234366yba.12 for ; 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 To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka 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 --- 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); From patchwork Tue Aug 18 07:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 11720179 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E89D3138C for ; Tue, 18 Aug 2020 07:34:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBFBF20786 for ; Tue, 18 Aug 2020 07:34:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oLXTjLg9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgHRHe0 (ORCPT ); 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 ); 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 ; Tue, 18 Aug 2020 00:34:25 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w11so21189954ybi.23 for ; 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 To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka 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