diff mbox series

[BlueZ] advertising: Fix setting "BR/EDR not supported" flag

Message ID 20230728044923.576144-1-simon.mikuda@streamunlimited.com (mailing list archive)
State Superseded
Headers show
Series [BlueZ] advertising: Fix setting "BR/EDR not supported" flag | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Simon Mikuda July 28, 2023, 4:49 a.m. UTC
We need to check if adapter is connectable since remote device can connect
to our device even when we are not discoverable according to advertised
MAC address.
---
 src/advertising.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com July 28, 2023, 6:30 a.m. UTC | #1
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=770394

---Test result---

Test Summary:
CheckPatch                    PASS      0.45 seconds
GitLint                       PASS      0.31 seconds
BuildEll                      PASS      32.24 seconds
BluezMake                     PASS      1169.96 seconds
MakeCheck                     PASS      12.86 seconds
MakeDistcheck                 PASS      187.52 seconds
CheckValgrind                 PASS      308.22 seconds
CheckSmatch                   PASS      423.85 seconds
bluezmakeextell               PASS      123.95 seconds
IncrementalBuild              PASS      1023.43 seconds
ScanBuild                     PASS      1342.03 seconds



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz July 28, 2023, 5:21 p.m. UTC | #2
Hi Simon,

On Thu, Jul 27, 2023 at 10:21 PM Simon Mikuda
<simon.mikuda@streamunlimited.com> wrote:
>
> We need to check if adapter is connectable since remote device can connect
> to our device even when we are not discoverable according to advertised
> MAC address.

This is actually intentional, we don't want to 'leak' bearer
information if we are not discoverable over BR/EDR since when we are
just connectable we don't respond to inquiries then we shouldn't
advertise it either.

If the use case you want to support is to use an advertisement to
indicate to the remote end to connect over BR/EDR then it is probably
a better idea to make it discoverable on both bearers, then that flag
wont get set.

> ---
>  src/advertising.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/advertising.c b/src/advertising.c
> index d959bf38f..b50900029 100644
> --- a/src/advertising.c
> +++ b/src/advertising.c
> @@ -95,6 +95,8 @@ struct dbus_obj_match {
>         const char *path;
>  };
>
> +static int get_adv_flags(struct btd_adv_client *client);
> +
>  static bool match_client(const void *a, const void *b)
>  {
>         const struct btd_adv_client *client = a;
> @@ -736,11 +738,11 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags)
>         if (!btd_adapter_get_bredr(client->manager->adapter))
>                 flags |= BT_AD_FLAG_NO_BREDR;
>
> -       /* Set BR/EDR Not Supported if adapter is not discoverable but the
> +       /* Set BR/EDR Not Supported if adapter is not connectable but the
>          * instance is.
>          */
> -       if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) &&
> -                       !btd_adapter_get_discoverable(client->manager->adapter))
> +       if ((get_adv_flags(client) & MGMT_ADV_FLAG_CONNECTABLE) &&
> +                       !btd_adapter_get_connectable(client->manager->adapter))
>                 flags |= BT_AD_FLAG_NO_BREDR;
>
>         if (!bt_ad_add_flags(client->data, &flags, 1))
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/src/advertising.c b/src/advertising.c
index d959bf38f..b50900029 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -95,6 +95,8 @@  struct dbus_obj_match {
 	const char *path;
 };
 
+static int get_adv_flags(struct btd_adv_client *client);
+
 static bool match_client(const void *a, const void *b)
 {
 	const struct btd_adv_client *client = a;
@@ -736,11 +738,11 @@  static bool set_flags(struct btd_adv_client *client, uint8_t flags)
 	if (!btd_adapter_get_bredr(client->manager->adapter))
 		flags |= BT_AD_FLAG_NO_BREDR;
 
-	/* Set BR/EDR Not Supported if adapter is not discoverable but the
+	/* Set BR/EDR Not Supported if adapter is not connectable but the
 	 * instance is.
 	 */
-	if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) &&
-			!btd_adapter_get_discoverable(client->manager->adapter))
+	if ((get_adv_flags(client) & MGMT_ADV_FLAG_CONNECTABLE) &&
+			!btd_adapter_get_connectable(client->manager->adapter))
 		flags |= BT_AD_FLAG_NO_BREDR;
 
 	if (!bt_ad_add_flags(client->data, &flags, 1))