From: Archie Pusaka <apusaka@google.com>
To: linux-bluetooth <linux-bluetooth@vger.kernel.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>
Cc: CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>,
Archie Pusaka <apusaka@chromium.org>,
Miao-chen Chou <mcchou@chromium.org>
Subject: [Bluez PATCH v4 4/5] main: add configurable RemoteNameRequestRetryDelay parameter
Date: Thu, 25 Nov 2021 15:06:26 +0800 [thread overview]
Message-ID: <20211125150558.Bluez.v4.4.Ia861c62203f9201b657a6e81f7612c5db415ac2c@changeid> (raw)
In-Reply-To: <20211125150558.Bluez.v4.1.I78857808e0b20c6e4dd934b174d3f1106fe3402d@changeid>
From: Archie Pusaka <apusaka@chromium.org>
This specifies how long will the userspace ignore a peer with an
unknown name after a failed remote name resolving procedure.
The peer device can still be connected, this only prevents the remote
name resolving procedure retry.
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
Changes in v4:
* New in this version.
src/btd.h | 1 +
src/device.c | 4 +---
src/main.c | 19 ++++++++++++++++---
src/main.conf | 5 +++++
4 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/btd.h b/src/btd.h
index ff9f082f19..a805a40d7d 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -104,6 +104,7 @@ struct btd_opts {
uint32_t tmpto;
uint8_t privacy;
bool device_privacy;
+ uint32_t name_request_retry_delay;
struct btd_defaults defaults;
diff --git a/src/device.c b/src/device.c
index 44450b1132..0e2612825b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -79,8 +79,6 @@
#define GATT_INCLUDE_UUID_STR "2802"
#define GATT_CHARAC_UUID_STR "2803"
-#define NAME_RESOLVE_RETRY_DELAY 300 /* seconds */
-
static DBusConnection *dbus_conn = NULL;
static unsigned service_state_cb_id;
@@ -4489,7 +4487,7 @@ bool device_is_name_resolve_allowed(struct btd_device *device)
*/
return now.tv_sec < device->name_resolve_failed_time ||
now.tv_sec >= device->name_resolve_failed_time +
- NAME_RESOLVE_RETRY_DELAY;
+ btd_opts.name_request_retry_delay;
}
void device_name_resolve_fail(struct btd_device *device)
diff --git a/src/main.c b/src/main.c
index 3adcdc1087..8cc2dfca61 100644
--- a/src/main.c
+++ b/src/main.c
@@ -55,9 +55,10 @@
#define BLUEZ_NAME "org.bluez"
-#define DEFAULT_PAIRABLE_TIMEOUT 0 /* disabled */
-#define DEFAULT_DISCOVERABLE_TIMEOUT 180 /* 3 minutes */
-#define DEFAULT_TEMPORARY_TIMEOUT 30 /* 30 seconds */
+#define DEFAULT_PAIRABLE_TIMEOUT 0 /* disabled */
+#define DEFAULT_DISCOVERABLE_TIMEOUT 180 /* 3 minutes */
+#define DEFAULT_TEMPORARY_TIMEOUT 30 /* 30 seconds */
+#define DEFAULT_NAME_REQUEST_RETRY_DELAY 300 /* 5 minutes */
#define SHUTDOWN_GRACE_SECONDS 10
@@ -82,6 +83,7 @@ static const char *supported_options[] = {
"JustWorksRepairing",
"TemporaryTimeout",
"Experimental",
+ "RemoteNameRequestRetryDelay",
NULL
};
@@ -816,6 +818,16 @@ static void parse_config(GKeyFile *config)
g_strfreev(strlist);
}
+ val = g_key_file_get_integer(config, "General",
+ "RemoteNameRequestRetryDelay", &err);
+ if (err) {
+ DBG("%s", err->message);
+ g_clear_error(&err);
+ } else {
+ DBG("RemoteNameRequestRetryDelay=%d", val);
+ btd_opts.name_request_retry_delay = val;
+ }
+
str = g_key_file_get_string(config, "GATT", "Cache", &err);
if (err) {
DBG("%s", err->message);
@@ -927,6 +939,7 @@ static void init_defaults(void)
btd_opts.name_resolv = TRUE;
btd_opts.debug_keys = FALSE;
btd_opts.refresh_discovery = TRUE;
+ btd_opts.name_request_retry_delay = DEFAULT_NAME_REQUEST_RETRY_DELAY;
btd_opts.defaults.num_entries = 0;
btd_opts.defaults.br.page_scan_type = 0xFFFF;
diff --git a/src/main.conf b/src/main.conf
index 0c41d77420..49b9e67550 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -119,6 +119,11 @@
# Defaults to false.
#Experimental = false
+# The duration to avoid retrying to resolve a peer's name, if the previous
+# try failed.
+# The value is in seconds. Default is 300, i.e. 5 minutes.
+#RemoteNameRequestRetryDelay = 300
+
[BR]
# The following values are used to load default adapter parameters for BR/EDR.
# BlueZ loads the values into the kernel before the adapter is powered if the
--
2.34.0.rc2.393.gf8c9666880-goog
next prev parent reply other threads:[~2021-11-25 7:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 7:06 [Bluez PATCH v4 1/5] mgmt: Add NAME_REQUEST_FAILED flag for device_found event Archie Pusaka
2021-11-25 7:06 ` [Bluez PATCH v4 2/5] Listen and process remote name resolving failure Archie Pusaka
2021-11-25 7:06 ` [Bluez PATCH v4 3/5] device: Save remote name request attempts into cache file Archie Pusaka
2021-11-25 7:06 ` Archie Pusaka [this message]
2021-11-25 7:06 ` [Bluez PATCH v4 5/5] doc: Add Name Request Fail flag in device found event Archie Pusaka
2021-11-25 7:37 ` [Bluez,v4,1/5] mgmt: Add NAME_REQUEST_FAILED flag for device_found event bluez.test.bot
2021-11-29 17:49 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211125150558.Bluez.v4.4.Ia861c62203f9201b657a6e81f7612c5db415ac2c@changeid \
--to=apusaka@google.com \
--cc=apusaka@chromium.org \
--cc=chromeos-bluetooth-upstreaming@chromium.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=mcchou@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).