Skip to contentSkip to conversation

main.conf: Add FilterDiscoverable option

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Sep 8, 2025 – Sep 9, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 main.conf: Add FilterDiscoverable option

From: Luiz Augusto von Dentz <[email protected]>

This adds FilterDiscoverable option which can be use to control if devices in non-discoverable mode shall be filtered or not, the default is true to adhere to core spec:

9.2. Discovery modes and procedures

All devices shall be in either non-discoverable mode or one of the discoverable modes. A device in the discoverable mode shall be in either the general discoverable mode or the limited discoverable mode. A device in the non-discoverable mode is not discoverable. Devices operating in either the general discoverable mode or the limited discoverable mode can be found by the discovering device.

---
 src/adapter.c | 4 +++-
 src/btd.h     | 1 +
 src/main.c    | 4 ++++
 src/main.conf | 9 +++++++++
 4 files changed, 17 insertions(+), 1 deletion(-)
src/adapter.c +3 -1
index 549a6c0b8324..dc5ba65d73fa 100644
@@ -7239,8 +7239,10 @@ static bool device_is_discoverable(struct btd_adapter *adapter,
 
 	if (bdaddr_type == BDADDR_BREDR || adapter->filtered_discovery)
 		discoverable = true;
-	else
+	else if (btd_opts.filter_discoverable)
 		discoverable = eir->flags & (EIR_LIM_DISC | EIR_GEN_DISC);
+	else
+		discoverable = true;
 
 	/*
 	 * Mark as not discoverable if no client has requested discovery and
src/btd.h +1 -0
index 18a5eb88696a..5c952bf17956 100644
@@ -142,6 +142,7 @@ struct btd_opts {
 	bool		refresh_discovery;
 	bool		experimental;
 	bool		testing;
+	bool		filter_discoverable;
 	struct queue	*kernel;
 
 	uint16_t	did_source;
src/main.c +4 -0
index a542d0fc50b0..1c7390e6329d 100644
@@ -91,6 +91,7 @@ static const char *supported_options[] = {
 	"Testing",
 	"KernelExperimental",
 	"RemoteNameRequestRetryDelay",
+	"FilterDiscoverable",
 	NULL
 };
 
@@ -1062,6 +1063,8 @@ static void parse_general(GKeyFile *config)
 	parse_config_u32(config, "General", "RemoteNameRequestRetryDelay",
 					&btd_opts.name_request_retry_delay,
 					0, UINT32_MAX);
+	parse_config_bool(config, "General", "FilterDiscoverable",
+						&btd_opts.filter_discoverable);
 }
 
 static void parse_gatt_cache(GKeyFile *config)
@@ -1239,6 +1242,7 @@ static void init_defaults(void)
 	btd_opts.refresh_discovery = TRUE;
 	btd_opts.name_request_retry_delay = DEFAULT_NAME_REQUEST_RETRY_DELAY;
 	btd_opts.secure_conn = SC_ON;
+	btd_opts.filter_discoverable = true;
 
 	btd_opts.defaults.num_entries = 0;
 	btd_opts.defaults.br.page_scan_type = 0xFFFF;
src/main.conf +9 -0
index 86759d53c1f2..4c53376dcec7 100644
@@ -148,6 +148,15 @@
 # The value is in seconds. Default is 300, i.e. 5 minutes.
 #RemoteNameRequestRetryDelay = 300
 
+# Filter out non-discoverable devices based on discoverable flags (General or
+# Limited).
+# Defaults to true
+# Setting to false is only recommended for an use-case where non-discoverable
+# device must be enumerated due to some requirement (e.g. not using GAP
+# discoverable modes for some odd reason which seems to be the behavior of
+# some stacks) or when testing bad/unintended behavior.
+#FilterDiscoverable = true
+
 [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
Signature · 1 line
2.51.0
#1 lore raw

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. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1000203

---Test result---

Test Summary:

CheckPatch                    PENDING   0.28 seconds
GitLint                       PENDING   0.33 seconds
BuildEll                      PASS      20.19 seconds
BluezMake                     PASS      2651.00 seconds
MakeCheck                     PASS      20.71 seconds
MakeDistcheck                 PASS      185.57 seconds
CheckValgrind                 PASS      237.49 seconds
CheckSmatch                   PASS      308.96 seconds
bluezmakeextell               PASS      128.73 seconds
IncrementalBuild              PENDING   0.23 seconds
ScanBuild                     PASS      923.13 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Luiz Augusto von Dentz
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Mon, 8 Sep 2025 17:38:33 -0400 you wrote:

From: Luiz Augusto von Dentz <[email protected]>

This adds FilterDiscoverable option which can be use to control if devices in non-discoverable mode shall be filtered or not, the default is true to adhere to core spec:

9.2. Discovery modes and procedures

[...]

Here is the summary with links:
- [BlueZ,v2] main.conf: Add FilterDiscoverable option

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=393e81a7473c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html