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 2/5] device: Make Connect and Pair mutually exclusive
Date: Wed, 26 Mar 2025 15:31:30 -0400	[thread overview]
Message-ID: <20250326193133.2718934-2-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>

This makes Device.Connect and Device.Pair methods mutually exclusive so
they cannot happen in parallel, so just as Connect:Connect and Pair:Pair
combinations the Connect:Pair and Pair:Connect will now return
org.bluez.Error.InProgress.
---
 src/device.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index f76c1ec3eabf..6a6c379fcbbf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2629,6 +2629,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
 	struct btd_device *dev = user_data;
 	uint8_t bdaddr_type;
 
+	if (dev->bonding)
+		return btd_error_in_progress(msg);
+
 	if (dev->bredr_state.connected) {
 		/*
 		 * Check if services have been resolved and there is at least
@@ -2648,6 +2651,9 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
 	if (bdaddr_type != BDADDR_BREDR) {
 		int err;
 
+		if (dev->connect)
+			return btd_error_in_progress(msg);
+
 		if (dev->le_state.connected)
 			return dbus_message_new_method_return(msg);
 
@@ -3133,7 +3139,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
 	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
 
-	if (device->bonding)
+	if (device->bonding || device->connect)
 		return btd_error_in_progress(msg);
 
 	/* Only use this selection algorithms when device is combo
-- 
2.48.1


  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 ` Luiz Augusto von Dentz [this message]
2025-03-26 19:31 ` [PATCH BlueZ v2 3/5] device: Use btd_device_is_initiator instead of Connect message Luiz Augusto von Dentz
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-2-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.