All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message
Date: Wed, 26 Mar 2025 15:31:31 -0400	[thread overview]
Message-ID: <20250326193133.2718934-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20250326193133.2718934-1-luiz.dentz@gmail.com>

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

Device.Connect message is not the only way to initiate a connection as
there is also the likes of Device.Pair which will initiate bonding, so
this incorporate the bonding check into btd_device_is_initiator and
replaces the checks of were Connect message was used to determine if
initiator to use btd_device_is_initiator.
---
 src/device.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 6a6c379fcbbf..034491b59d30 100644
--- a/src/device.c
+++ b/src/device.c
@@ -320,6 +320,8 @@ bool btd_device_is_initiator(struct btd_device *dev)
 		return dev->le_state.initiator;
 	else if (dev->bredr_state.connected)
 		return dev->bredr_state.initiator;
+	else if (dev->bonding)
+		return true;
 
 	return dev->att_io ? true : false;
 }
@@ -5780,11 +5782,12 @@ static void gatt_client_init(struct btd_device *device)
 
 	gatt_client_cleanup(device);
 
-	if (!device->connect && !btd_opts.reverse_discovery) {
+	if (!btd_device_is_initiator(device) && !btd_opts.reverse_discovery) {
 		DBG("Reverse service discovery disabled: skipping GATT client");
 		return;
 	}
-	if (!device->connect && !btd_opts.gatt_client) {
+
+	if (!btd_device_is_initiator(device) && !btd_opts.gatt_client) {
 		DBG("GATT client disabled: skipping GATT client");
 		return;
 	}
@@ -5834,7 +5837,7 @@ static void gatt_client_init(struct btd_device *device)
 	 * it shall be triggered only when ready to avoid possible clashes where
 	 * both sides attempt to connection at same time.
 	 */
-	if (device->connect)
+	if (btd_device_is_initiator(device))
 		btd_gatt_client_eatt_connect(device->client_dbus);
 }
 
-- 
2.48.1


  parent reply	other threads:[~2025-03-26 19:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 19:31 [PATCH BlueZ v2 1/5] device: Attempt to elevate security on Pair while connected Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 2/5] device: Make Connect and Pair mutually exclusive Luiz Augusto von Dentz
2025-03-26 19:31 ` Luiz Augusto von Dentz [this message]
2025-03-26 19:31 ` [PATCH BlueZ v2 4/5] shared/att: Make bt_att_set_security never downgrade security level Luiz Augusto von Dentz
2025-03-26 19:31 ` [PATCH BlueZ v2 5/5] device: Elevate bt_att security if bonding is in progress Luiz Augusto von Dentz
2025-03-26 20:31 ` [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected bluez.test.bot
2025-03-27 16:10 ` [PATCH BlueZ v2 1/5] " patchwork-bot+bluetooth

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=20250326193133.2718934-3-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.