All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] device: Fix not always storing device info
@ 2023-03-08  0:51 Luiz Augusto von Dentz
  2023-03-08  0:51 ` [PATCH BlueZ 2/2] gatt: Fix creating duplicated objects Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2023-03-08  0:51 UTC (permalink / raw)
  To: linux-bluetooth

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

When updating the device address check if the device is marked as
temporary before attempting to call store_device_info otherwise it will
have no effect and instead btd_device_set_temporary must be called.
---
 src/device.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index df50ce7b4f6c..652c03606b9e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4412,7 +4412,10 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
 	bacpy(&device->bdaddr, bdaddr);
 	device->bdaddr_type = bdaddr_type;
 
-	store_device_info(device);
+	if (device->temporary)
+		btd_device_set_temporary(device, false);
+	else
+		store_device_info(device);
 
 	g_dbus_emit_property_changed(dbus_conn, device->path,
 						DEVICE_INTERFACE, "Address");
-- 
2.39.2


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

* [PATCH BlueZ 2/2] gatt: Fix creating duplicated objects
  2023-03-08  0:51 [PATCH BlueZ 1/2] device: Fix not always storing device info Luiz Augusto von Dentz
@ 2023-03-08  0:51 ` Luiz Augusto von Dentz
  2023-03-08  2:19 ` [BlueZ,1/2] device: Fix not always storing device info bluez.test.bot
  2023-03-11  0:40 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2023-03-08  0:51 UTC (permalink / raw)
  To: linux-bluetooth

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

This checks cid before attempting to create device, if the device is
using an RPA it could be that the MGMT event has not been processed yet
which would lead to create a second copy of the same device using its
identity address.
---
 src/gatt-database.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index ea282d4bc193..3b53bf2a3c84 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -632,6 +632,7 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	struct btd_device *device;
 	uint8_t dst_type;
 	bdaddr_t src, dst;
+	uint16_t cid;
 
 	if (gerr) {
 		error("%s", gerr->message);
@@ -641,6 +642,7 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	bt_io_get(io, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src,
 						BT_IO_OPT_DEST_BDADDR, &dst,
 						BT_IO_OPT_DEST_TYPE, &dst_type,
+						BT_IO_OPT_CID, &cid,
 						BT_IO_OPT_INVALID);
 	if (gerr) {
 		error("bt_io_get: %s", gerr->message);
@@ -655,9 +657,21 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	if (!adapter)
 		return;
 
-	device = btd_adapter_get_device(adapter, &dst, dst_type);
-	if (!device)
+	/* Check cid before attempting to create device, if the device is using
+	 * an RPA it could be that the MGMT event has not been processed yet
+	 * which would lead to create a second copy of the same device using its
+	 * identity address.
+	 */
+	if (cid == BT_ATT_CID)
+		device = btd_adapter_get_device(adapter, &dst, dst_type);
+	else
+		device = btd_adapter_find_device(adapter, &dst, dst_type);
+
+	if (!device) {
+		error("Unable to find device, dropping connection attempt");
+		g_io_channel_shutdown(io, FALSE, NULL);
 		return;
+	}
 
 	device_attach_att(device, io);
 }
-- 
2.39.2


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

* RE: [BlueZ,1/2] device: Fix not always storing device info
  2023-03-08  0:51 [PATCH BlueZ 1/2] device: Fix not always storing device info Luiz Augusto von Dentz
  2023-03-08  0:51 ` [PATCH BlueZ 2/2] gatt: Fix creating duplicated objects Luiz Augusto von Dentz
@ 2023-03-08  2:19 ` bluez.test.bot
  2023-03-11  0:40 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2023-03-08  2:19 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1293 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=727684

---Test result---

Test Summary:
CheckPatch                    PASS      0.71 seconds
GitLint                       PASS      0.49 seconds
BuildEll                      PASS      26.25 seconds
BluezMake                     PASS      763.65 seconds
MakeCheck                     PASS      11.06 seconds
MakeDistcheck                 PASS      154.66 seconds
CheckValgrind                 PASS      241.74 seconds
CheckSmatch                   PASS      323.62 seconds
bluezmakeextell               PASS      97.21 seconds
IncrementalBuild              PASS      1235.69 seconds
ScanBuild                     WARNING   983.36 seconds

Details
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
src/gatt-database.c:1152:10: warning: Value stored to 'bits' during its initialization is never read
        uint8_t bits[] = { BT_GATT_CHRC_CLI_FEAT_ROBUST_CACHING,
                ^~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ 1/2] device: Fix not always storing device info
  2023-03-08  0:51 [PATCH BlueZ 1/2] device: Fix not always storing device info Luiz Augusto von Dentz
  2023-03-08  0:51 ` [PATCH BlueZ 2/2] gatt: Fix creating duplicated objects Luiz Augusto von Dentz
  2023-03-08  2:19 ` [BlueZ,1/2] device: Fix not always storing device info bluez.test.bot
@ 2023-03-11  0:40 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2023-03-11  0:40 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue,  7 Mar 2023 16:51:57 -0800 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> When updating the device address check if the device is marked as
> temporary before attempting to call store_device_info otherwise it will
> have no effect and instead btd_device_set_temporary must be called.
> ---
>  src/device.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [BlueZ,1/2] device: Fix not always storing device info
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=581aae6a2722
  - [BlueZ,2/2] gatt: Fix creating duplicated objects
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3842320f450e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-03-11  0:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  0:51 [PATCH BlueZ 1/2] device: Fix not always storing device info Luiz Augusto von Dentz
2023-03-08  0:51 ` [PATCH BlueZ 2/2] gatt: Fix creating duplicated objects Luiz Augusto von Dentz
2023-03-08  2:19 ` [BlueZ,1/2] device: Fix not always storing device info bluez.test.bot
2023-03-11  0:40 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth

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.