Skip to content

bluetooth: improve the controller address resolution enablement #90705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

MarkWangChinese
Copy link
Collaborator

If the controller resolving list is cleared by HCI_LE_Clear_Resolving_List, don't need to enable the controller address resolution.

I think it is one improvement, please help to review.

alwa-nordic
alwa-nordic previously approved these changes May 28, 2025
Thalley
Thalley previously approved these changes May 28, 2025
@Thalley Thalley requested a review from Copilot May 28, 2025 15:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines when the Bluetooth controller’s address resolution is re-enabled by introducing a flag to skip re-enabling if disabling failed or the resolving list was cleared.

  • Add enable_controller_res flag initialized to true.
  • Set the flag to false on disable failure or after clearing the resolving list.
  • Wrap the final addr_res_enable(BT_HCI_ADDR_RES_ENABLE) call in a conditional based on the flag.
Comments suppressed due to low confidence (2)

subsys/bluetooth/host/id.c:1014

  • [nitpick] Consider renaming enable_controller_res to should_enable_controller_res or reenable_controller_res for clearer intent.
bool enable_controller_res = true;

subsys/bluetooth/host/id.c:1085

  • Add a test case to cover the scenario where the resolving list is cleared so that address resolution is not re-enabled.
enable_controller_res = false;

@MarkWangChinese MarkWangChinese dismissed stale reviews from Thalley and alwa-nordic via fa5b640 June 3, 2025 04:03
@MarkWangChinese MarkWangChinese force-pushed the feature/improve_controller_addr_resolution_enable branch from 381c212 to fa5b640 Compare June 3, 2025 04:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Improve controller address resolution enablement by skipping re-enablement when the resolving list is cleared or when a disable command fails.

  • Introduce enable_controller_res flag to track whether resolution should be re-enabled
  • Set flag to false on disable failure and after clearing the resolving list
  • Wrap final addr_res_enable(BT_HCI_ADDR_RES_ENABLE) call in a conditional based on the flag
Comments suppressed due to low confidence (3)

subsys/bluetooth/host/id.c:1014

  • [nitpick] The variable name enable_controller_res is a bit ambiguous. Consider renaming it to something like should_enable_addr_res or should_reenable_controller_res for clarity.
bool enable_controller_res = true;

subsys/bluetooth/host/id.c:1126

  • The return value of addr_res_enable is not checked here. It would be safer to capture and log any error to aid debugging if re-enablement fails.
addr_res_enable(BT_HCI_ADDR_RES_ENABLE);

subsys/bluetooth/host/id.c:1085

  • Add tests to cover the scenario where the resolving list is cleared and enable_controller_res is false, ensuring address resolution isn’t re-enabled unexpectedly.
enable_controller_res = false;

Comment on lines 1082 to 1083
/* since the controller resolving list is cleared,
* don't need to enable the Address Resolution.
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Minor: consider adjusting comment capitalization and consistency, e.g., "address resolution" in lowercase, to match code style.

Suggested change
/* since the controller resolving list is cleared,
* don't need to enable the Address Resolution.
/* Since the controller resolving list is cleared,
* don't need to enable the address resolution.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor typing stuff in the comments, otherwise LGTM

@MarkWangChinese MarkWangChinese force-pushed the feature/improve_controller_addr_resolution_enable branch from fa5b640 to 892407c Compare June 3, 2025 08:14
If the controller resolving list is cleared by HCI_LE_Clear_Resolving_List,
don't need to enable the controller address resolution.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
@MarkWangChinese MarkWangChinese force-pushed the feature/improve_controller_addr_resolution_enable branch from 892407c to 56c5dbc Compare June 3, 2025 08:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines when the controller’s address resolution is re-enabled by introducing a flag to skip re-enablement if the resolving list was just cleared or if disabling failed.

  • Add enable_controller_res flag to track whether to call addr_res_enable at the end
  • Set flag to false when disable fails or when the resolving list is cleared
  • Wrap final addr_res_enable(BT_HCI_ADDR_RES_ENABLE) in a conditional based on the new flag
Comments suppressed due to low confidence (2)

subsys/bluetooth/host/id.c:1014

  • [nitpick] The flag name enable_controller_res can be ambiguous. Consider renaming it to something like should_enable_controller_res to clearly indicate it controls whether re-enablement should occur.
bool enable_controller_res = true;

subsys/bluetooth/host/id.c:1085

  • This new path where enable_controller_res is set to false after clearing the resolving list should be covered by a unit or integration test to ensure resolution is not re-enabled in this scenario.
enable_controller_res = false;

@@ -1067,13 +1068,21 @@ void bt_id_add(struct bt_keys *keys)
err = addr_res_enable(BT_HCI_ADDR_RES_DISABLE);
if (err) {
LOG_WRN("Failed to disable address resolution");
/* If it fails to disable, it should already be enabled,
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment could be clearer and more concise. For example: /* On disable failure, resolution remains enabled—no need to re-enable. */

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Jun 3, 2025

@kartben kartben merged commit 2d4e05a into zephyrproject-rtos:main Jun 3, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants