public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] shared/att: Fix accepting Exchange MTU on EATT bearer
@ 2021-08-25 21:14 Luiz Augusto von Dentz
  2021-08-25 21:14 ` [PATCH BlueZ 2/3] shared/att: Fix attempting to send " Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-25 21:14 UTC (permalink / raw)
  To: linux-bluetooth

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

If remote send Exchange MTU it shall fail as the MTU negotiation shall
happen over L2CAP signalling not ATT for those channels.
---
 src/shared/att.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index ccc753c4e..665d7f4b8 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -962,7 +962,8 @@ static void handle_notify(struct bt_att_chan *chan, uint8_t *pdu,
 		 * link since the MTU size is negotiated using L2CAP channel
 		 * configuration procedures.
 		 */
-		if (bt_att_get_link_type(att) == BT_ATT_BREDR) {
+		if (bt_att_get_link_type(att) == BT_ATT_BREDR ||
+				chan->type == BT_ATT_EATT) {
 			switch (opcode) {
 			case BT_ATT_OP_MTU_REQ:
 				goto not_supported;
-- 
2.31.1


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

* [PATCH BlueZ 2/3] shared/att: Fix attempting to send Exchange MTU on EATT bearer
  2021-08-25 21:14 [PATCH BlueZ 1/3] shared/att: Fix accepting Exchange MTU on EATT bearer Luiz Augusto von Dentz
@ 2021-08-25 21:14 ` Luiz Augusto von Dentz
  2021-08-25 21:14 ` [PATCH BlueZ 3/3] gatt: Do not always attempt to connect EATT immediately Luiz Augusto von Dentz
  2021-08-25 21:33 ` [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-25 21:14 UTC (permalink / raw)
  To: linux-bluetooth

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

EATT bearer shall use the L2CAP signalling for negotiating the MTU
size.
---
 src/shared/att.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index 665d7f4b8..329497728 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -411,10 +411,17 @@ static struct att_send_op *pick_next_send_op(struct bt_att_chan *chan)
 	 */
 	if (!chan->pending_req) {
 		op = queue_peek_head(att->req_queue);
-		if (op && op->len <= chan->mtu)
+		if (op && op->len <= chan->mtu) {
+			/* Don't send Exchange MTU over EATT */
+			if (op->opcode == BT_ATT_OP_MTU_REQ &&
+					chan->type == BT_ATT_EATT)
+				goto indicate;
+
 			return queue_pop_head(att->req_queue);
+		}
 	}
 
+indicate:
 	/* There is either a request pending or no requests queued. If there is
 	 * no pending indication, pick an operation from the indication queue.
 	 */
-- 
2.31.1


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

* [PATCH BlueZ 3/3] gatt: Do not always attempt to connect EATT immediately
  2021-08-25 21:14 [PATCH BlueZ 1/3] shared/att: Fix accepting Exchange MTU on EATT bearer Luiz Augusto von Dentz
  2021-08-25 21:14 ` [PATCH BlueZ 2/3] shared/att: Fix attempting to send " Luiz Augusto von Dentz
@ 2021-08-25 21:14 ` Luiz Augusto von Dentz
  2021-08-25 21:33 ` [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-25 21:14 UTC (permalink / raw)
  To: linux-bluetooth

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

Wait the bt_gatt_client becomes ready (has performed service discovery)
before attempting to connect EATT when acting as peripheral/acceptor
since the central/initiator might actually attempt to connect EATT
channels in the same way which can potentially cause a collisions.
---
 src/device.c      |  7 +++++
 src/gatt-client.c | 74 +++++++++++++++++++++++------------------------
 src/gatt-client.h |  1 +
 3 files changed, 44 insertions(+), 38 deletions(-)

diff --git a/src/device.c b/src/device.c
index 998485be7..6253edc77 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5304,6 +5304,13 @@ static void gatt_client_init(struct btd_device *device)
 	}
 
 	btd_gatt_client_connected(device->client_dbus);
+
+	/* Only initiate EATT connection when acting as initiator, as acceptor
+	 * it shall be triggered only when ready to avoid possible clashes where
+	 * both sides attempt to connection at same time.
+	 */
+	if (device->connect)
+		bt_gatt_client_eatt_connect(device->client_dbus);
 }
 
 static void gatt_server_init(struct btd_device *device,
diff --git a/src/gatt-client.c b/src/gatt-client.c
index bec6e1ec0..6cf96365d 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -2156,6 +2156,38 @@ static void register_notify(void *data, void *user_data)
 	notify_client_free(notify_client);
 }
 
+void btd_gatt_client_ready(struct btd_gatt_client *client)
+{
+	if (!client)
+		return;
+
+	if (!client->gatt) {
+		struct bt_gatt_client *gatt;
+
+		gatt = btd_device_get_gatt_client(client->device);
+		client->gatt = bt_gatt_client_clone(gatt);
+		if (!client->gatt) {
+			error("GATT client not initialized");
+			return;
+		}
+	}
+
+	client->ready = true;
+
+	DBG("GATT client ready");
+
+	create_services(client);
+
+	DBG("Features 0x%02x", client->features);
+
+	if (!client->features) {
+		client->features = bt_gatt_client_get_features(client->gatt);
+		DBG("Update Features 0x%02x", client->features);
+		if (client->features & BT_GATT_CHRC_CLI_FEAT_EATT)
+			bt_gatt_client_eatt_connect(client);
+	}
+}
+
 static void eatt_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 {
 	struct btd_gatt_client *client = user_data;
@@ -2166,7 +2198,7 @@ static void eatt_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	device_attach_att(client->device, io);
 }
 
-static void eatt_connect(struct btd_gatt_client *client)
+void bt_gatt_client_eatt_connect(struct btd_gatt_client *client)
 {
 	struct bt_att *att = bt_gatt_client_get_att(client->gatt);
 	struct btd_device *dev = client->device;
@@ -2176,6 +2208,9 @@ static void eatt_connect(struct btd_gatt_client *client)
 	char addr[18];
 	int i;
 
+	if (!(client->features & BT_GATT_CHRC_CLI_FEAT_EATT))
+		return;
+
 	if (bt_att_get_channels(att) == btd_opts.gatt_channels)
 		return;
 
@@ -2232,38 +2267,6 @@ static void eatt_connect(struct btd_gatt_client *client)
 	}
 }
 
-void btd_gatt_client_ready(struct btd_gatt_client *client)
-{
-	if (!client)
-		return;
-
-	if (!client->gatt) {
-		struct bt_gatt_client *gatt;
-
-		gatt = btd_device_get_gatt_client(client->device);
-		client->gatt = bt_gatt_client_clone(gatt);
-		if (!client->gatt) {
-			error("GATT client not initialized");
-			return;
-		}
-	}
-
-	client->ready = true;
-
-	DBG("GATT client ready");
-
-	create_services(client);
-
-	DBG("Features 0x%02x", client->features);
-
-	if (!client->features) {
-		client->features = bt_gatt_client_get_features(client->gatt);
-		DBG("Update Features 0x%02x", client->features);
-		if (client->features & BT_GATT_CHRC_CLI_FEAT_EATT)
-			eatt_connect(client);
-	}
-}
-
 void btd_gatt_client_connected(struct btd_gatt_client *client)
 {
 	struct bt_gatt_client *gatt;
@@ -2284,11 +2287,6 @@ void btd_gatt_client_connected(struct btd_gatt_client *client)
 	 * for any pre-registered notification sessions.
 	 */
 	queue_foreach(client->all_notify_clients, register_notify, client);
-
-	if (!(client->features & BT_GATT_CHRC_CLI_FEAT_EATT))
-		return;
-
-	eatt_connect(client);
 }
 
 void btd_gatt_client_service_added(struct btd_gatt_client *client,
diff --git a/src/gatt-client.h b/src/gatt-client.h
index b6539207e..672c5e72f 100644
--- a/src/gatt-client.h
+++ b/src/gatt-client.h
@@ -20,6 +20,7 @@ void btd_gatt_client_service_added(struct btd_gatt_client *client,
 void btd_gatt_client_service_removed(struct btd_gatt_client *client,
 					struct gatt_db_attribute *attrib);
 void btd_gatt_client_disconnected(struct btd_gatt_client *client);
+void bt_gatt_client_eatt_connect(struct btd_gatt_client *client);
 
 typedef void (*btd_gatt_client_service_path_t)(const char *service_path,
 							void *user_data);
-- 
2.31.1


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

* RE: [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer
  2021-08-25 21:14 [PATCH BlueZ 1/3] shared/att: Fix accepting Exchange MTU on EATT bearer Luiz Augusto von Dentz
  2021-08-25 21:14 ` [PATCH BlueZ 2/3] shared/att: Fix attempting to send " Luiz Augusto von Dentz
  2021-08-25 21:14 ` [PATCH BlueZ 3/3] gatt: Do not always attempt to connect EATT immediately Luiz Augusto von Dentz
@ 2021-08-25 21:33 ` bluez.test.bot
  2021-08-25 22:13   ` Luiz Augusto von Dentz
  2 siblings, 1 reply; 5+ messages in thread
From: bluez.test.bot @ 2021-08-25 21:33 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

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

---Test result---

Test Summary:
CheckPatch                    PASS      0.80 seconds
GitLint                       PASS      0.32 seconds
Prep - Setup ELL              PASS      42.62 seconds
Build - Prep                  PASS      0.15 seconds
Build - Configure             PASS      7.72 seconds
Build - Make                  PASS      190.27 seconds
Make Check                    PASS      9.03 seconds
Make Distcheck                PASS      224.50 seconds
Build w/ext ELL - Configure   PASS      7.65 seconds
Build w/ext ELL - Make        PASS      178.82 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth


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

* Re: [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer
  2021-08-25 21:33 ` [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer bluez.test.bot
@ 2021-08-25 22:13   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-08-25 22:13 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi,

On Wed, Aug 25, 2021 at 2:33 PM <bluez.test.bot@gmail.com> wrote:
>
> 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=537355
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    PASS      0.80 seconds
> GitLint                       PASS      0.32 seconds
> Prep - Setup ELL              PASS      42.62 seconds
> Build - Prep                  PASS      0.15 seconds
> Build - Configure             PASS      7.72 seconds
> Build - Make                  PASS      190.27 seconds
> Make Check                    PASS      9.03 seconds
> Make Distcheck                PASS      224.50 seconds
> Build w/ext ELL - Configure   PASS      7.65 seconds
> Build w/ext ELL - Make        PASS      178.82 seconds
>
> Details
> ##############################
> Test: CheckPatch - PASS
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
>
> ##############################
> Test: GitLint - PASS
> Desc: Run gitlint with rule in .gitlint
>
> ##############################
> Test: Prep - Setup ELL - PASS
> Desc: Clone, build, and install ELL
>
> ##############################
> Test: Build - Prep - PASS
> Desc: Prepare environment for build
>
> ##############################
> Test: Build - Configure - PASS
> Desc: Configure the BlueZ source tree
>
> ##############################
> Test: Build - Make - PASS
> Desc: Build the BlueZ source tree
>
> ##############################
> Test: Make Check - PASS
> Desc: Run 'make check'
>
> ##############################
> Test: Make Distcheck - PASS
> Desc: Run distcheck to check the distribution
>
> ##############################
> Test: Build w/ext ELL - Configure - PASS
> Desc: Configure BlueZ source with '--enable-external-ell' configuration
>
> ##############################
> Test: Build w/ext ELL - Make - PASS
> Desc: Build BlueZ source with '--enable-external-ell' configuration
>
>
>
> ---
> Regards,
> Linux Bluetooth
>

Pushed.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2021-08-25 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-25 21:14 [PATCH BlueZ 1/3] shared/att: Fix accepting Exchange MTU on EATT bearer Luiz Augusto von Dentz
2021-08-25 21:14 ` [PATCH BlueZ 2/3] shared/att: Fix attempting to send " Luiz Augusto von Dentz
2021-08-25 21:14 ` [PATCH BlueZ 3/3] gatt: Do not always attempt to connect EATT immediately Luiz Augusto von Dentz
2021-08-25 21:33 ` [BlueZ,1/3] shared/att: Fix accepting Exchange MTU on EATT bearer bluez.test.bot
2021-08-25 22:13   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox