* [PATCH BlueZ] device: Fix not handling initiator properly
@ 2023-09-11 22:33 Luiz Augusto von Dentz
2023-09-12 2:10 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2023-09-11 22:33 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Previously initiator would be set whenever a central key was found
which turns out to be unreliable besides the MGMT New Connection event
does in fact inform if the connection was initiated locally or not.
Fixes: https://github.com/bluez/bluez/issues/598
---
src/adapter.c | 10 ++++++----
src/device.c | 15 +++++----------
src/device.h | 3 ++-
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 5ebfc4752a7e..8a7c53a9e3ce 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5163,9 +5163,10 @@ static void adapter_remove_device(struct btd_adapter *adapter,
static void adapter_add_connection(struct btd_adapter *adapter,
struct btd_device *device,
- uint8_t bdaddr_type)
+ uint8_t bdaddr_type,
+ uint32_t flags)
{
- device_add_connection(device, bdaddr_type);
+ device_add_connection(device, bdaddr_type, flags);
if (g_slist_find(adapter->connections, device)) {
btd_error(adapter->dev_id,
@@ -5218,7 +5219,7 @@ static void get_connections_complete(uint8_t status, uint16_t length,
device = btd_adapter_get_device(adapter, &addr->bdaddr,
addr->type);
if (device)
- adapter_add_connection(adapter, device, addr->type);
+ adapter_add_connection(adapter, device, addr->type, 0);
}
}
@@ -9426,7 +9427,8 @@ static void connected_callback(uint16_t index, uint16_t length,
if (eir_data.class != 0)
device_set_class(device, eir_data.class);
- adapter_add_connection(adapter, device, ev->addr.type);
+ adapter_add_connection(adapter, device, ev->addr.type,
+ le32_to_cpu(ev->flags));
name_known = device_name_known(device);
diff --git a/src/device.c b/src/device.c
index 9b58e0c4e6c5..35ce1df0fe74 100644
--- a/src/device.c
+++ b/src/device.c
@@ -312,16 +312,9 @@ static struct bearer_state *get_state(struct btd_device *dev,
bool btd_device_is_initiator(struct btd_device *dev)
{
- if (dev->le_state.connected) {
- /* Mark as initiator if not set yet and auto-connect flag is
- * set and LTK key is for a peripheral.
- */
- if (!dev->le_state.initiator && dev->auto_connect &&
- dev->ltk && !dev->ltk->central)
- dev->le_state.initiator = true;
-
+ if (dev->le_state.connected)
return dev->le_state.initiator;
- } else if (dev->bredr_state.connected)
+ else if (dev->bredr_state.connected)
return dev->bredr_state.initiator;
return dev->att_io ? true : false;
@@ -3226,7 +3219,8 @@ static void clear_temporary_timer(struct btd_device *dev)
}
}
-void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type)
+void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type,
+ uint32_t flags)
{
struct bearer_state *state = get_state(dev, bdaddr_type);
@@ -3249,6 +3243,7 @@ void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type)
device_set_le_support(dev, bdaddr_type);
state->connected = true;
+ state->initiator = flags & BIT(3);
if (dev->le_state.connected && dev->bredr_state.connected)
return;
diff --git a/src/device.h b/src/device.h
index 3252e14eff84..0a9e51533ca5 100644
--- a/src/device.h
+++ b/src/device.h
@@ -124,7 +124,8 @@ int device_notify_pincode(struct btd_device *device, gboolean secure,
const char *pincode);
void device_cancel_authentication(struct btd_device *device, gboolean aborted);
gboolean device_is_authenticating(struct btd_device *device);
-void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type);
+void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type,
+ uint32_t flags);
void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
bool *remove);
void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [BlueZ] device: Fix not handling initiator properly
2023-09-11 22:33 [PATCH BlueZ] " Luiz Augusto von Dentz
@ 2023-09-12 2:02 ` bluez.test.bot
0 siblings, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-09-12 2:02 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 947 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=783186
---Test result---
Test Summary:
CheckPatch PASS 0.44 seconds
GitLint PASS 0.27 seconds
BuildEll PASS 32.98 seconds
BluezMake PASS 981.12 seconds
MakeCheck PASS 13.94 seconds
MakeDistcheck PASS 186.99 seconds
CheckValgrind PASS 307.42 seconds
CheckSmatch PASS 404.91 seconds
bluezmakeextell PASS 122.37 seconds
IncrementalBuild PASS 805.23 seconds
ScanBuild PASS 1241.03 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [BlueZ] device: Fix not handling initiator properly
2023-09-11 22:33 [PATCH BlueZ] device: Fix not handling initiator properly Luiz Augusto von Dentz
@ 2023-09-12 2:10 ` bluez.test.bot
0 siblings, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-09-12 2:10 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 948 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=783190
---Test result---
Test Summary:
CheckPatch PASS 0.52 seconds
GitLint PASS 0.32 seconds
BuildEll PASS 32.21 seconds
BluezMake PASS 1114.35 seconds
MakeCheck PASS 12.42 seconds
MakeDistcheck PASS 185.98 seconds
CheckValgrind PASS 310.03 seconds
CheckSmatch PASS 436.18 seconds
bluezmakeextell PASS 130.22 seconds
IncrementalBuild PASS 983.51 seconds
ScanBuild PASS 1371.65 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-12 2:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 22:33 [PATCH BlueZ] device: Fix not handling initiator properly Luiz Augusto von Dentz
2023-09-12 2:10 ` [BlueZ] " bluez.test.bot
-- strict thread matches above, loose matches on Subject: below --
2023-09-11 22:33 [PATCH BlueZ] " Luiz Augusto von Dentz
2023-09-12 2:02 ` [BlueZ] " 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).