public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] monitor: Fix not loading local GATT DB from cache
@ 2026-04-06 20:00 Luiz Augusto von Dentz
  2026-04-06 20:55 ` [BlueZ,v1] " bluez.test.bot
  2026-04-07 13:30 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-06 20:00 UTC (permalink / raw)
  To: linux-bluetooth

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

The local GATT DB maybe discover in previous connection and therefore
should be cached as well to be able to decode follow-up connections
where the discovery may not be visible.
---
 monitor/att.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/monitor/att.c b/monitor/att.c
index e76cb44d28f5..e8e0d499a826 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -412,12 +412,24 @@ static bool match_cache_id(const void *data, const void *match_data)
 	return !bacmp(&cache->id, id);
 }
 
-static void gatt_cache_add(struct packet_conn_data *conn, struct gatt_db *db)
+static void gatt_cache_add(struct packet_conn_data *conn, struct gatt_db *ldb,
+							struct gatt_db *rdb)
 {
 	struct gatt_cache *cache;
 	bdaddr_t id;
 	uint8_t id_type;
 
+	/* Attempt to cache local db if not empty */
+	if (!gatt_db_isempty(ldb)) {
+		cache = new0(struct gatt_cache, 1);
+		bacpy(&cache->id, (bdaddr_t *)conn->src);
+		cache->db = gatt_db_ref(ldb);
+		queue_push_tail(cache_list, cache);
+	}
+
+	if (gatt_db_isempty(rdb))
+		return;
+
 	if (!keys_resolve_identity(conn->dst, id.b, &id_type))
 		bacpy(&id, (bdaddr_t *)conn->dst);
 
@@ -429,7 +441,7 @@ static void gatt_cache_add(struct packet_conn_data *conn, struct gatt_db *db)
 
 	cache = new0(struct gatt_cache, 1);
 	bacpy(&cache->id, &id);
-	cache->db = gatt_db_ref(db);
+	cache->db = gatt_db_ref(rdb);
 	queue_push_tail(cache_list, cache);
 }
 
@@ -437,8 +449,7 @@ static void att_conn_data_free(struct packet_conn_data *conn, void *data)
 {
 	struct att_conn_data *att_data = data;
 
-	if (!gatt_db_isempty(att_data->rdb))
-		gatt_cache_add(conn, att_data->rdb);
+	gatt_cache_add(conn, att_data->ldb, att_data->rdb);
 
 	gatt_db_unref(att_data->rdb);
 	gatt_db_unref(att_data->ldb);
@@ -520,6 +531,10 @@ static void load_gatt_db(struct packet_conn_data *conn)
 		cache = queue_find(cache_list, match_cache_id, &id);
 		if (cache)
 			data->rdb = gatt_db_ref(cache->db);
+
+		cache = queue_find(cache_list, match_cache_id, &conn->src);
+		if (cache)
+			data->ldb = gatt_db_ref(cache->db);
 	}
 }
 
-- 
2.53.0


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

end of thread, other threads:[~2026-04-07 13:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-06 20:00 [PATCH BlueZ v1] monitor: Fix not loading local GATT DB from cache Luiz Augusto von Dentz
2026-04-06 20:55 ` [BlueZ,v1] " bluez.test.bot
2026-04-07 13:30 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

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