* [PATCH] Bluetooth: Fix mgmt connected notification
@ 2014-11-10 15:10 johan.hedberg
2014-11-10 23:04 ` Marcel Holtmann
2014-11-11 9:33 ` [PATCH v2] " johan.hedberg
0 siblings, 2 replies; 4+ messages in thread
From: johan.hedberg @ 2014-11-10 15:10 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch fixes a regression that was introduced by commit
cb77c3ec075a50e9f956f62dc2e4c0394df1d578. In addition to BT_CONFIG,
BT_CONNECTED is also a state in which we may get a remote name and need
to indicate over mgmt the connection status. This scenario is
particularly likely to happen for incoming connections that do not need
authentication since there the hci_conn state will reach BT_CONNECTED
before the remote name is received.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_event.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 68c882fd20fd..a97af145e7ec 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1581,7 +1581,8 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
struct discovery_state *discov = &hdev->discovery;
struct inquiry_entry *e;
- if (conn && conn->state == BT_CONFIG &&
+ if (conn &&
+ (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) &&
!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
mgmt_device_connected(hdev, conn, 0, name, name_len);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Bluetooth: Fix mgmt connected notification
2014-11-10 15:10 [PATCH] Bluetooth: Fix mgmt connected notification johan.hedberg
@ 2014-11-10 23:04 ` Marcel Holtmann
2014-11-11 9:33 ` [PATCH v2] " johan.hedberg
1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2014-11-10 23:04 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch fixes a regression that was introduced by commit
> cb77c3ec075a50e9f956f62dc2e4c0394df1d578. In addition to BT_CONFIG,
> BT_CONNECTED is also a state in which we may get a remote name and need
> to indicate over mgmt the connection status. This scenario is
> particularly likely to happen for incoming connections that do not need
> authentication since there the hci_conn state will reach BT_CONNECTED
> before the remote name is received.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_event.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 68c882fd20fd..a97af145e7ec 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1581,7 +1581,8 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
> struct discovery_state *discov = &hdev->discovery;
> struct inquiry_entry *e;
>
> - if (conn && conn->state == BT_CONFIG &&
> + if (conn &&
> + (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) &&
> !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
> mgmt_device_connected(hdev, conn, 0, name, name_len);
lets add a comment explain this detail right in the code. I am sure in a week from now we all have forgotten why this statement is so complex.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Bluetooth: Fix mgmt connected notification
2014-11-10 15:10 [PATCH] Bluetooth: Fix mgmt connected notification johan.hedberg
2014-11-10 23:04 ` Marcel Holtmann
@ 2014-11-11 9:33 ` johan.hedberg
2014-11-11 9:36 ` Marcel Holtmann
1 sibling, 1 reply; 4+ messages in thread
From: johan.hedberg @ 2014-11-11 9:33 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch fixes a regression that was introduced by commit
cb77c3ec075a50e9f956f62dc2e4c0394df1d578. In addition to BT_CONFIG,
BT_CONNECTED is also a state in which we may get a remote name and need
to indicate over mgmt the connection status. This scenario is
particularly likely to happen for incoming connections that do not need
authentication since there the hci_conn state will reach BT_CONNECTED
before the remote name is received.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
v2: Added code comment to explain the conn->state checks
net/bluetooth/hci_event.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 68c882fd20fd..aec3b1dce1cc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1581,7 +1581,13 @@ static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
struct discovery_state *discov = &hdev->discovery;
struct inquiry_entry *e;
- if (conn && conn->state == BT_CONFIG &&
+ /* Update the mgmt connected state if necessary. Be careful with
+ * conn objects that exist but are not (yet) connected however.
+ * Only those in BT_CONFIG or BT_CONNECTED states can be
+ * considered connected.
+ */
+ if (conn &&
+ (conn->state == BT_CONFIG || conn->state == BT_CONNECTED) &&
!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
mgmt_device_connected(hdev, conn, 0, name, name_len);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Bluetooth: Fix mgmt connected notification
2014-11-11 9:33 ` [PATCH v2] " johan.hedberg
@ 2014-11-11 9:36 ` Marcel Holtmann
0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2014-11-11 9:36 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch fixes a regression that was introduced by commit
> cb77c3ec075a50e9f956f62dc2e4c0394df1d578. In addition to BT_CONFIG,
> BT_CONNECTED is also a state in which we may get a remote name and need
> to indicate over mgmt the connection status. This scenario is
> particularly likely to happen for incoming connections that do not need
> authentication since there the hci_conn state will reach BT_CONNECTED
> before the remote name is received.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> v2: Added code comment to explain the conn->state checks
>
> net/bluetooth/hci_event.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-11 9:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 15:10 [PATCH] Bluetooth: Fix mgmt connected notification johan.hedberg
2014-11-10 23:04 ` Marcel Holtmann
2014-11-11 9:33 ` [PATCH v2] " johan.hedberg
2014-11-11 9:36 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox