linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option
@ 2025-09-04 16:33 Luiz Augusto von Dentz
  2025-09-04 17:53 ` [BlueZ,v2] " bluez.test.bot
  2025-09-08 11:30 ` [PATCH BlueZ v2] " Bastien Nocera
  0 siblings, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-09-04 16:33 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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 | 5 +++++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index 549a6c0b8324..dc5ba65d73fa 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -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
diff --git a/src/btd.h b/src/btd.h
index 18a5eb88696a..5c952bf17956 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -142,6 +142,7 @@ struct btd_opts {
 	bool		refresh_discovery;
 	bool		experimental;
 	bool		testing;
+	bool		filter_discoverable;
 	struct queue	*kernel;
 
 	uint16_t	did_source;
diff --git a/src/main.c b/src/main.c
index a542d0fc50b0..1c7390e6329d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
diff --git a/src/main.conf b/src/main.conf
index 86759d53c1f2..55618be5c923 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -148,6 +148,11 @@
 # 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
+#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
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [BlueZ,v2] main.conf: Add FilterDiscoverable option
  2025-09-04 16:33 [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option Luiz Augusto von Dentz
@ 2025-09-04 17:53 ` bluez.test.bot
  2025-09-08 11:30 ` [PATCH BlueZ v2] " Bastien Nocera
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-09-04 17:53 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

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=998967

---Test result---

Test Summary:
CheckPatch                    PENDING   0.33 seconds
GitLint                       PENDING   0.52 seconds
BuildEll                      PASS      19.74 seconds
BluezMake                     PASS      2535.74 seconds
MakeCheck                     PASS      19.73 seconds
MakeDistcheck                 PASS      186.00 seconds
CheckValgrind                 PASS      235.81 seconds
CheckSmatch                   PASS      308.71 seconds
bluezmakeextell               PASS      130.27 seconds
IncrementalBuild              PENDING   0.41 seconds
ScanBuild                     PASS      914.51 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option
  2025-09-04 16:33 [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option Luiz Augusto von Dentz
  2025-09-04 17:53 ` [BlueZ,v2] " bluez.test.bot
@ 2025-09-08 11:30 ` Bastien Nocera
  2025-09-08 21:32   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 5+ messages in thread
From: Bastien Nocera @ 2025-09-08 11:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth

On Thu, 2025-09-04 at 12:33 -0400, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> 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:

This needs more explanation as to where the filter is defined.

What happens if no filter is defined and FilterDiscoverable is set to
true?

In which circumstances would a system builder, integrator or admin want
to set this to false?

>  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 | 5 +++++
>  4 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/adapter.c b/src/adapter.c
> index 549a6c0b8324..dc5ba65d73fa 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -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
> diff --git a/src/btd.h b/src/btd.h
> index 18a5eb88696a..5c952bf17956 100644
> --- a/src/btd.h
> +++ b/src/btd.h
> @@ -142,6 +142,7 @@ struct btd_opts {
>  	bool		refresh_discovery;
>  	bool		experimental;
>  	bool		testing;
> +	bool		filter_discoverable;
>  	struct queue	*kernel;
>  
>  	uint16_t	did_source;
> diff --git a/src/main.c b/src/main.c
> index a542d0fc50b0..1c7390e6329d 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -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_dis
> coverable);
>  }
>  
>  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;
> diff --git a/src/main.conf b/src/main.conf
> index 86759d53c1f2..55618be5c923 100644
> --- a/src/main.conf
> +++ b/src/main.conf
> @@ -148,6 +148,11 @@
>  # 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
> +#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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option
  2025-09-08 11:30 ` [PATCH BlueZ v2] " Bastien Nocera
@ 2025-09-08 21:32   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-09-08 21:32 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hi Bastien,

On Mon, Sep 8, 2025 at 7:30 AM Bastien Nocera <hadess@hadess.net> wrote:
>
> On Thu, 2025-09-04 at 12:33 -0400, Luiz Augusto von Dentz wrote:
> > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> >
> > 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:
>
> This needs more explanation as to where the filter is defined.
>
> What happens if no filter is defined and FilterDiscoverable is set to
> true?

Well that is the current behavior where non-discoverable devices are
not enumerated, the behavior of filters are bypass the discoverable
flag:

When discovery filter is set, Device objects will be created as new
devices with matching criteria are discovered regardless of they are
connectable or discoverable which enables listening to non-connectable
and non-discoverable devices.
[]https://gist.github.com/Vudentz/0e7b34b596c7bf91e4bfd76fe46f9662


> In which circumstances would a system builder, integrator or admin want
> to set this to false?

Id wouldn't recommend setting to false except if the system is being
used with specific use case that requires to ignore the remote
discoverable settings or for testing bad or unintended behavior, well
perhaps it would have been clearer if I just include the above in the
documentation.

>
> >  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 | 5 +++++
> >  4 files changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 549a6c0b8324..dc5ba65d73fa 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -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
> > diff --git a/src/btd.h b/src/btd.h
> > index 18a5eb88696a..5c952bf17956 100644
> > --- a/src/btd.h
> > +++ b/src/btd.h
> > @@ -142,6 +142,7 @@ struct btd_opts {
> >       bool            refresh_discovery;
> >       bool            experimental;
> >       bool            testing;
> > +     bool            filter_discoverable;
> >       struct queue    *kernel;
> >
> >       uint16_t        did_source;
> > diff --git a/src/main.c b/src/main.c
> > index a542d0fc50b0..1c7390e6329d 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -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_dis
> > coverable);
> >  }
> >
> >  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;
> > diff --git a/src/main.conf b/src/main.conf
> > index 86759d53c1f2..55618be5c923 100644
> > --- a/src/main.conf
> > +++ b/src/main.conf
> > @@ -148,6 +148,11 @@
> >  # 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
> > +#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



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [BlueZ,v2] main.conf: Add FilterDiscoverable option
  2025-09-08 21:38 Luiz Augusto von Dentz
@ 2025-09-08 23:00 ` bluez.test.bot
  0 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-09-08 23:00 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-08 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04 16:33 [PATCH BlueZ v2] main.conf: Add FilterDiscoverable option Luiz Augusto von Dentz
2025-09-04 17:53 ` [BlueZ,v2] " bluez.test.bot
2025-09-08 11:30 ` [PATCH BlueZ v2] " Bastien Nocera
2025-09-08 21:32   ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2025-09-08 21:38 Luiz Augusto von Dentz
2025-09-08 23:00 ` [BlueZ,v2] " bluez.test.bot

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).