Skip to contentSkip to conversation

emulator/btdev: Update the white list and resolving list size

RFC PATCH Superseded Tedd Ho-Jeong An 3 participants 6 messages Jun 26, 2021 – Jul 1, 2021 Bluetooth drivers

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v4 1/3 emulator/btdev: Update the white list and resolving list size

From: Tedd Ho-Jeong An <[email protected]>

This patch updates the white list and resolving list size to small number.
Also, it update the size of white list and resolving list to 1 more than actual size when it is read via HCI read size commands. This is used to simulate the case when the list is out of space.

Note that the read list size may not represent the current actual list size depends on the device vendor.

---
 emulator/btdev.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
emulator/btdev.c +14 -4
index 90457a5aa..202fc7996 100644
@@ -33,8 +33,8 @@
 #include "monitor/bt.h"
 #include "btdev.h"
 
-#define WL_SIZE			16
-#define RL_SIZE			16
+#define WL_SIZE			3
+#define RL_SIZE			3
 #define CIS_SIZE		3
 
 #define has_bredr(btdev)	(!((btdev)->features[4] & 0x20))
@@ -3402,7 +3402,12 @@ static int cmd_read_wl_size(struct btdev *dev, const void *data, uint8_t len)
 	struct bt_hci_rsp_le_read_white_list_size rsp;
 
 	rsp.status = BT_HCI_ERR_SUCCESS;
-	rsp.size = WL_SIZE;
+	/* The size is not fixed and the actual list size can be different from
+	 * the returned size here.
+	 * In order to test such cases, return more than allocated size, and
+	 * HCI Add device cmd will return the Memory Capacity Exceeded(0x07)
+	 */
+	rsp.size = WL_SIZE + 1;
 	cmd_complete(dev, BT_HCI_CMD_LE_READ_WHITE_LIST_SIZE, &rsp,
 						sizeof(rsp));
 
@@ -3687,7 +3692,12 @@ static int cmd_read_rl_size(struct btdev *dev, const void *data, uint8_t len)
 	struct bt_hci_rsp_le_read_resolv_list_size rsp;
 
 	rsp.status = BT_HCI_ERR_SUCCESS;
-	rsp.size = RL_SIZE;
+	/* The size is not fixed and the actual list size can be different from
+	 * the returned size here.
+	 * In order to test such cases, return more than allocated size, and
+	 * HCI Add device cmd will return the Memory Capacity Exceeded(0x07)
+	 */
+	rsp.size = RL_SIZE + 1;
 
 	cmd_complete(dev, BT_HCI_CMD_LE_READ_RESOLV_LIST_SIZE,
 							&rsp, sizeof(rsp));
Signature · 1 line
2.26.3
#1 lore raw

RFC PATCH v4 2/3 emulator/btdev: clean up the queue before closing the test

From: Tedd Ho-Jeong An <[email protected]>

This patch clean up the queue for connection before closing the test to prevent the potential memory leak.

==50== 32 bytes in 1 blocks are definitely lost in loss record 18 of 32

==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x13178E: create_vhci (hciemu.c:229)
==50==    by 0x13178E: hciemu_new_num (hciemu.c:403)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==
==50== 32 bytes in 1 blocks are definitely lost in loss record 19 of 32
==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x1318F7: hciemu_client_new (hciemu.c:332)
==50==    by 0x1318F7: hciemu_new_num (hciemu.c:412)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
---
 emulator/btdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
emulator/btdev.c +4 -1
index 202fc7996..75cca7549 100644
@@ -624,8 +624,10 @@ static void conn_unlink(struct btdev_conn *conn1, struct btdev_conn *conn2)
 	conn2->link = NULL;
 }
 
-static void conn_remove(struct btdev_conn *conn)
+static void conn_remove(void *data)
 {
+	struct btdev_conn *conn = data;
+
 	if (conn->link) {
 		struct btdev_conn *link = conn->link;
 
@@ -6056,6 +6058,7 @@ void btdev_destroy(struct btdev *btdev)
 	bt_crypto_unref(btdev->crypto);
 	del_btdev(btdev);
 
+	queue_destroy(btdev->conns, conn_remove);
 	queue_destroy(btdev->le_ext_adv, le_ext_adv_free);
 
 	free(btdev);
Signature · 1 line
2.26.3
#2 lore raw

Re: [RFC BlueZ PATCH v4 2/3] emulator/btdev: clean up the queue before closing the test

Hi Tedd,

Quoted 64 lines · Tedd Ho-Jeong An

From: Tedd Ho-Jeong An <[email protected]>

This patch clean up the queue for connection before closing the test to prevent the potential memory leak.

==50== 32 bytes in 1 blocks are definitely lost in loss record 18 of 32

==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x13178E: create_vhci (hciemu.c:229)
==50==    by 0x13178E: hciemu_new_num (hciemu.c:403)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==
==50== 32 bytes in 1 blocks are definitely lost in loss record 19 of 32
==50==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==50==    by 0x14A37E: btd_malloc (util.c:33)
==50==    by 0x149D9D: queue_new (queue.c:47)
==50==    by 0x13B3C0: btdev_create (btdev.c:6042)
==50==    by 0x1318F7: hciemu_client_new (hciemu.c:332)
==50==    by 0x1318F7: hciemu_new_num (hciemu.c:412)
==50==    by 0x130E2C: read_index_list_callback (mgmt-tester.c:357)
==50==    by 0x14AD91: request_complete (mgmt.c:264)
==50==    by 0x14BD34: can_read_data (mgmt.c:356)
==50==    by 0x14E794: watch_callback (io-glib.c:157)
==50==    by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
==50==    by 0x48B5E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
---
 emulator/btdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
emulator/btdev.c +4 -2
index 202fc7996..75cca7549 100644
@@ -624,8 +624,10 @@ static void conn_unlink(struct btdev_conn *conn1, struct btdev_conn *conn2)
        conn2->link = NULL;
 }
 
-static void conn_remove(struct btdev_conn *conn)
+static void conn_remove(void *data)
 {
+       struct btdev_conn *conn = data;
+
        if (conn->link) {
                struct btdev_conn *link = conn->link;
 
@@ -6056,6 +6058,7 @@ void btdev_destroy(struct btdev *btdev)
        bt_crypto_unref(btdev->crypto);
        del_btdev(btdev);
 
+       queue_destroy(btdev->conns, conn_remove);
        queue_destroy(btdev->le_ext_adv, le_ext_adv_free);
 
        free(btdev);
--
Quoted 1 line

2.26.3

Ive pushed this one.

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

RFC PATCH v4 3/3 tools/mgmt-tester: Add LL Privacy test cases

In reply to Tedd Ho-Jeong An

From: Tedd Ho-Jeong An <[email protected]>

This patch adds LL Privacy related test cases.

Multi Ext Advertising - Success 3 (Add 2 Advs) Multi Ext Advertising - Success 4 (Remove Adv) Multi Ext Advertising - Success 5 (Remove all) Multi Ext Advertising - Fail (Add MAX)

LL Privacy - Add Device 1 (Add to WL)
LL Privacy - Add Device 2 (Add to RL)
LL Privacy - Add Device 3 (Enable RL)
LL Privacy - Add Device 4 (2 Devices to WL) LL Privacy - Add Device 5 (2 Devices to RL) LL Privacy - Add Device 6 (RL is full)
LL Privacy - Add Device 7 (WL is full)
LL Privacy - Add Device 8 (Disable Adv)
LL Privacy - Add Device 9 (Multi Adv)
LL Privacy - Add Device 10 (Multi Dev and Multi Adv)

LL Privacy - Remove Device 1 (Remove from WL) LL Privacy - Remove Device 2 (Remove from RL) LL Privacy - Remove Device 3 (Disable RL) LL Privacy - Remove Device 4 (Disable Adv) LL Privacy - Remove Device 5 (Multi Adv)

LL Privacy - Start Discovery 1 (Disable RL) LL Privacy - Start Discovery 2 (Disable RL)

---
 emulator/btdev.c    |    2 +-
 tools/mgmt-tester.c | 1542 +++++++++++++++++++++++++++++++++++--------
 2 files changed, 1258 insertions(+), 286 deletions(-)
emulator/btdev.c +1 -1
index 75cca7549..71d55846c 100644
@@ -4633,7 +4633,7 @@ static int cmd_remove_adv_set(struct btdev *dev, const void *data,
 						UINT_TO_PTR(cmd->handle));
 	if (!ext_adv) {
 		status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
-		cmd_complete(dev, BT_HCI_CMD_LE_SET_EXT_ADV_DATA, &status,
+		cmd_complete(dev, BT_HCI_CMD_LE_REMOVE_ADV_SET, &status,
 						sizeof(status));
 		return 0;
 	}
tools/mgmt-tester.c +1257 -285

1,725 lines not on this page · raw message

Signature · 1 line
2.26.3
#4 lore raw
In reply to Tedd Ho-Jeong An

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=507457

---Test result---

Test Summary:

CheckPatch                    FAIL      2.14 seconds
GitLint                       FAIL      0.35 seconds
Prep - Setup ELL              PASS      46.45 seconds
Build - Prep                  PASS      0.14 seconds
Build - Configure             PASS      8.02 seconds
Build - Make                  PASS      202.40 seconds
Make Check                    PASS      9.53 seconds
Make Distcheck                PASS      239.28 seconds
Build w/ext ELL - Configure   PASS      8.24 seconds
Build w/ext ELL - Make        PASS      190.10 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
emulator/btdev: clean up the queue before closing the test WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #20:
==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)

- total: 0 errors, 1 warnings, 18 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] emulator/btdev: clean up the queue before closing the test" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
emulator/btdev: clean up the queue before closing the test
17: B1 Line exceeds max length (87>80): "==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)"
32: B1 Line exceeds max length (87>80): "==50== by 0x48B578E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)"

##############################
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

#5 lore raw
In reply to Tedd Ho-Jeong An

Hi Tedd,

Quoted 59 lines · Tedd Ho-Jeong An

From: Tedd Ho-Jeong An <[email protected]>

This patch updates the white list and resolving list size to small number.
Also, it update the size of white list and resolving list to 1 more than actual size when it is read via HCI read size commands. This is used to simulate the case when the list is out of space.

Note that the read list size may not represent the current actual list size depends on the device vendor.

---
 emulator/btdev.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
emulator/btdev.c +14 -5
index 90457a5aa..202fc7996 100644
@@ -33,8 +33,8 @@
 #include "monitor/bt.h"
 #include "btdev.h"
 
-#define WL_SIZE                        16
-#define RL_SIZE                        16
+#define WL_SIZE                        3
+#define RL_SIZE                        3
 #define CIS_SIZE               3
 
 #define has_bredr(btdev)       (!((btdev)->features[4] & 0x20))
@@ -3402,7 +3402,12 @@ static int cmd_read_wl_size(struct btdev *dev, const void *data, uint8_t len)
        struct bt_hci_rsp_le_read_white_list_size rsp;
 
        rsp.status = BT_HCI_ERR_SUCCESS;
-       rsp.size = WL_SIZE;
+       /* The size is not fixed and the actual list size can be different from
+        * the returned size here.
+        * In order to test such cases, return more than allocated size, and
+        * HCI Add device cmd will return the Memory Capacity Exceeded(0x07)
+        */
+       rsp.size = WL_SIZE + 1;
        cmd_complete(dev, BT_HCI_CMD_LE_READ_WHITE_LIST_SIZE, &rsp,
                                                sizeof(rsp));
 
@@ -3687,7 +3692,12 @@ static int cmd_read_rl_size(struct btdev *dev, const void *data, uint8_t len)
        struct bt_hci_rsp_le_read_resolv_list_size rsp;
 
        rsp.status = BT_HCI_ERR_SUCCESS;
-       rsp.size = RL_SIZE;
+       /* The size is not fixed and the actual list size can be different from
+        * the returned size here.
+        * In order to test such cases, return more than allocated size, and
+        * HCI Add device cmd will return the Memory Capacity Exceeded(0x07)
+        */
+       rsp.size = RL_SIZE + 1;
 
        cmd_complete(dev, BT_HCI_CMD_LE_READ_RESOLV_LIST_SIZE,
                                                        &rsp, sizeof(rsp));
--
Quoted 1 line

2.26.3

This one I think we need to rework somehow, the idea is that we have this lists set dynamically in order to test the HCI error so Id have some function limit the amount of instances that can be used instead of reporting a wrong number like this.

Signature · 1 line
Luiz Augusto von Dentz