All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device
@ 2021-08-18 23:06 Luiz Augusto von Dentz
  2021-08-18 23:06 ` [RFC 2/3] btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-18 23:06 UTC (permalink / raw)
  To: linux-bluetooth

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

The device where the event should be sent is the same that had created
not the connection one.
---
 emulator/btdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 6e1d3c346..cd0cfa45f 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5118,7 +5118,7 @@ static void ext_adv_term(void *data, void *user_data)
 
 	/* if connectable bit is set the send adv terminate */
 	if (conn && adv->type & 0x01) {
-		adv_set_terminate(conn->dev, 0x00, adv->handle, conn->handle,
+		adv_set_terminate(adv->dev, 0x00, adv->handle, conn->handle,
 									0x00);
 		le_ext_adv_free(adv);
 	}
-- 
2.31.1


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

* [RFC 2/3] btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM
  2021-08-18 23:06 [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
@ 2021-08-18 23:06 ` Luiz Augusto von Dentz
  2021-08-18 23:06 ` [RFC 3/3] btdev: Fix removing advertising set if it was terminated Luiz Augusto von Dentz
  2021-08-19 18:34 ` [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-18 23:06 UTC (permalink / raw)
  To: linux-bluetooth

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

BT_HCI_EVT_LE_ADV_SET_TERM shall come after
BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE otherwise the host doesn't know
the connection handle.
---
 emulator/btdev.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index cd0cfa45f..7e9fa14c2 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5129,22 +5129,17 @@ static void le_ext_conn_complete(struct btdev *btdev,
 			struct le_ext_adv *ext_adv,
 			uint8_t status)
 {
+	struct btdev_conn *conn = NULL;
 	struct bt_hci_evt_le_enhanced_conn_complete ev;
 	struct bt_hci_le_ext_create_conn *lecc = (void *)cmd->data;
 
 	memset(&ev, 0, sizeof(ev));
 
 	if (!status) {
-		struct btdev_conn *conn;
-
 		conn = conn_add_acl(btdev, cmd->peer_addr, cmd->peer_addr_type);
 		if (!conn)
 			return;
 
-		/* Disable EXT ADV */
-		queue_foreach(btdev->le_ext_adv, ext_adv_term, conn);
-		queue_foreach(conn->link->dev->le_ext_adv, ext_adv_term, conn);
-
 		ev.status = status;
 		ev.peer_addr_type = btdev->le_scan_own_addr_type;
 		if (ev.peer_addr_type == 0x01)
@@ -5166,6 +5161,9 @@ static void le_ext_conn_complete(struct btdev *btdev,
 		le_meta_event(conn->link->dev,
 				BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE, &ev,
 				sizeof(ev));
+
+		/* Disable EXT ADV */
+		queue_foreach(conn->link->dev->le_ext_adv, ext_adv_term, conn);
 	}
 
 	ev.status = status;
@@ -5177,6 +5175,10 @@ static void le_ext_conn_complete(struct btdev *btdev,
 
 	le_meta_event(btdev, BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE, &ev,
 						sizeof(ev));
+
+	/* Disable EXT ADV */
+	if (conn)
+		queue_foreach(btdev->le_ext_adv, ext_adv_term, conn);
 }
 
 static int cmd_ext_create_conn_complete(struct btdev *dev, const void *data,
-- 
2.31.1


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

* [RFC 3/3] btdev: Fix removing advertising set if it was terminated
  2021-08-18 23:06 [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
  2021-08-18 23:06 ` [RFC 2/3] btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM Luiz Augusto von Dentz
@ 2021-08-18 23:06 ` Luiz Augusto von Dentz
  2021-08-19 18:34 ` [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-18 23:06 UTC (permalink / raw)
  To: linux-bluetooth

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

Consider the advertising set disabled but don't remove it as the host
may still reuse it.
---
 emulator/btdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 7e9fa14c2..4a4c8bdcd 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5120,7 +5120,7 @@ static void ext_adv_term(void *data, void *user_data)
 	if (conn && adv->type & 0x01) {
 		adv_set_terminate(adv->dev, 0x00, adv->handle, conn->handle,
 									0x00);
-		le_ext_adv_free(adv);
+		ext_adv_disable(adv, NULL);
 	}
 }
 
-- 
2.31.1


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

* Re: [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device
  2021-08-18 23:06 [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
  2021-08-18 23:06 ` [RFC 2/3] btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM Luiz Augusto von Dentz
  2021-08-18 23:06 ` [RFC 3/3] btdev: Fix removing advertising set if it was terminated Luiz Augusto von Dentz
@ 2021-08-19 18:34 ` Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-19 18:34 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Wed, Aug 18, 2021 at 4:06 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> The device where the event should be sent is the same that had created
> not the connection one.
> ---
>  emulator/btdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emulator/btdev.c b/emulator/btdev.c
> index 6e1d3c346..cd0cfa45f 100644
> --- a/emulator/btdev.c
> +++ b/emulator/btdev.c
> @@ -5118,7 +5118,7 @@ static void ext_adv_term(void *data, void *user_data)
>
>         /* if connectable bit is set the send adv terminate */
>         if (conn && adv->type & 0x01) {
> -               adv_set_terminate(conn->dev, 0x00, adv->handle, conn->handle,
> +               adv_set_terminate(adv->dev, 0x00, adv->handle, conn->handle,
>                                                                         0x00);
>                 le_ext_adv_free(adv);
>         }
> --
> 2.31.1
>

Pushed.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2021-08-19 18:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 23:06 [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz
2021-08-18 23:06 ` [RFC 2/3] btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM Luiz Augusto von Dentz
2021-08-18 23:06 ` [RFC 3/3] btdev: Fix removing advertising set if it was terminated Luiz Augusto von Dentz
2021-08-19 18:34 ` [RFC 1/3] btdev: Fix sending terminate advertising event to the wrong device Luiz Augusto von Dentz

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.