Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] mgmt-tester: Add LL Privacy host-resolved RPA scan checks
Date: Wed, 14 Oct 2026 14:11:53 -0400	[thread overview]
Message-ID: <20261014181153.1559666-1-luiz.dentz@gmail.com> (raw)

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

Controllers with LL Privacy resolve RPAs themselves, so peers with an
IRK can be kept in the accept list and passive scanning shall use the
accept list filter policy.

Assisted-by: OpenCode:claude-opus-5.5
---
 tools/mgmt-tester.c | 84 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 13484a6632ff..631c906f3aa8 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -10758,6 +10758,70 @@ static const struct generic_data host_rpa_no_irk_autoconnect = {
 	.expect_hci_param_check_func = host_rpa_filtered_check,
 };
 
+static const uint8_t ll_privacy_rpa_filtered[] = {
+	0x00,			/* Own Address Type */
+	0x01,			/* Filter Policy - Accept List */
+	0x05,			/* PHYs - 1M and Coded */
+	0x00,			/* Type - Passive */
+	0x60, 0x00,		/* Interval */
+	0x30, 0x00,		/* Window */
+	0x00,			/* Type - Passive */
+	0x60, 0x00,		/* Interval */
+	0x30, 0x00,		/* Window */
+};
+
+static int ll_privacy_rpa_filtered_check(const void *param, uint16_t length)
+{
+	const struct bt_hci_cmd_le_set_ext_scan_params *cp = param;
+	const struct bt_hci_le_scan_phy *phy = (void *) cp->data;
+
+	if (length != sizeof(ll_privacy_rpa_filtered))
+		return -EINVAL;
+
+	return cp->filter_policy != 0x01 || phy[0].type != 0x00 ||
+							phy[1].type != 0x00;
+}
+
+static const struct generic_data ll_privacy_rpa_autoconnect = {
+	.setup_settings = settings_powered_le,
+	.setup_send_opcode = MGMT_OP_LOAD_IRKS,
+	.setup_send_param = load_irks_le_public_param_1,
+	.setup_send_len = sizeof(load_irks_le_public_param_1),
+	.send_opcode = MGMT_OP_ADD_DEVICE,
+	.send_param = add_device_le_public_param_1,
+	.send_len = sizeof(add_device_le_public_param_1),
+	.expect_param = add_device_rsp_le_public,
+	.expect_len = sizeof(add_device_rsp_le_public),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+	.expect_alt_ev_param = add_device_le_public_param_1,
+	.expect_alt_ev_len = sizeof(add_device_le_public_param_1),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = ll_privacy_rpa_filtered,
+	.expect_hci_len = sizeof(ll_privacy_rpa_filtered),
+	.expect_hci_param_check_func = ll_privacy_rpa_filtered_check,
+};
+
+static const struct generic_data ll_privacy_rpa_report = {
+	.setup_settings = settings_powered_le,
+	.setup_send_opcode = MGMT_OP_LOAD_IRKS,
+	.setup_send_param = load_irks_le_public_param_1,
+	.setup_send_len = sizeof(load_irks_le_public_param_1),
+	.send_opcode = MGMT_OP_ADD_DEVICE,
+	.send_param = host_rpa_report_param,
+	.send_len = sizeof(host_rpa_report_param),
+	.expect_param = add_device_rsp_le_public,
+	.expect_len = sizeof(add_device_rsp_le_public),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_alt_ev = MGMT_EV_DEVICE_ADDED,
+	.expect_alt_ev_param = host_rpa_report_param,
+	.expect_alt_ev_len = sizeof(host_rpa_report_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = ll_privacy_rpa_filtered,
+	.expect_hci_len = sizeof(ll_privacy_rpa_filtered),
+	.expect_hci_param_check_func = ll_privacy_rpa_filtered_check,
+};
+
 static const struct generic_data host_rpa_no_irk_report = {
 	.setup_settings = settings_powered_le,
 	.send_opcode = MGMT_OP_ADD_DEVICE,
@@ -15856,6 +15920,26 @@ int main(int argc, char *argv[])
 	test_bredrle("Scan RPA - Background report without IRK",
 			&host_rpa_no_irk_report, NULL, test_command_generic);
 
+	/* LL Privacy
+	 * Setup: Enable LE, load IRK and Power On
+	 * Run: Add new device with auto-connect
+	 * Expect: Passive scanning uses the accept list since the controller
+	 *         resolves RPAs
+	 */
+	test_bredrle50("LL Privacy - Scan RPA - Auto-connect with IRK",
+				&ll_privacy_rpa_autoconnect,
+				setup_command_generic, test_command_generic);
+
+	/* LL Privacy
+	 * Setup: Enable LE, load IRK and Power On
+	 * Run: Add new device with background report
+	 * Expect: Passive scanning uses the accept list since the controller
+	 *         resolves RPAs
+	 */
+	test_bredrle50("LL Privacy - Scan RPA - Background report with IRK",
+				&ll_privacy_rpa_report,
+				setup_command_generic, test_command_generic);
+
 	/* LL Privacy
 	 * Setup: Enable LE and Power On
 	 * Run: Add new device
-- 
2.56.0


             reply	other threads:[~2026-10-14 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 18:11 Luiz Augusto von Dentz [this message]
2026-10-14 21:53 ` [BlueZ,v1] mgmt-tester: Add LL Privacy host-resolved RPA scan checks bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261014181153.1559666-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox