-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Bluetooth: Host: Fix not clearing IDs and keys upon bt_disable() #72680
Bluetooth: Host: Fix not clearing IDs and keys upon bt_disable() #72680
Conversation
rugeGerritsen
commented
May 13, 2024
•
edited
edited
tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable_set_default_id.sh
Outdated
Show resolved
Hide resolved
9d8ef17
to
b8e00c0
Compare
b8e00c0
to
45c80b1
Compare
@@ -35,6 +35,55 @@ static void test_disable_main(void) | |||
PASS("Disable test passed\n"); | |||
} | |||
|
|||
static void test_disable_set_default_id(void) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | |
{ | |
/* Provide some idle time for boot sequence to complete. | |
* Otherwise, it is observed that nRF POWER_CLOCK ISR does not get serviced. | |
*/ | |
k_sleep(K_MSEC(1)); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aescolar any comments, why some test case work without this hack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. I would need to dig into why that is happening, but I don't have time now. It would be nice if you or Emil did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thalley you are facing controller assertions, is similar workaround needed for your tests too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I haven't seen it for the bt_disable tests I'm implementing right now (#72690)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you already have couple k_sleep()
calls that would allow ISRs to be vectored into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a temporary workaround. #73342 fixes the bug in the controller
45c80b1
to
a792cde
Compare
70c6ad8
to
c11681c
Compare
/* BSIM test framework requires at to run some time before marking a | ||
* test case as passed. | ||
*/ | ||
k_sleep(K_MSEC(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thalley it is because of this: 919d27b#r142428001
The new CIS disable test is failing because |
If we are clearing stuff like IRKs etc. (which I believe we are/should when doing an HCI reset), then we should clear all the other keys as well, unless they are store in BT_SETTINGS. |
/* FIXME: Temporary workaround to get around a bug in the controller | ||
* Open PR: https://github.com/zephyrproject-rtos/zephyr/pull/73342 | ||
*/ | ||
k_sleep(K_MSEC(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Describe the symptom of the bug so it can be reproducible. As I see, it is the POWER_CLOCK_IRQn that is not executed if a test is developed without any cpu_idle() call.
- The workaround to sleep is only needed once, not needed in a loop. See the original suggestion here: https://github.com/zephyrproject-rtos/zephyr/pull/72680/files#r1599770565
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the description. Hopefully it can be removed soon. The linked PR should give enough information
c11681c
to
b5450a2
Compare
b5450a2
to
323adb4
Compare
bt_dev.le.rl_entries = 0; | ||
bt_keys_reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should bt_dev.le.rl_entries = 0;
have been part of bt_keys_reset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should we have a bt_id_reset
that does this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will leave that up to you and @jori-nordic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rugeGerritsen let's merge as-is and follow-up with another one if necessary. id.c
is "here be dragons" territory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
323adb4
to
9bd0e01
Compare
Expectation: After calling `bt_disable()` it is possible to use the Bluetooth APIs as if `bt_enable()` was never called. This was not the case for `bt_id_create()`, it was not possible to set the default identity. This prevented an application developer to restart the stack as a different identity. Keys also need to be cleared to avoid the following pattern: 1. Pair two devices 2. Central calls `bt_disable()` and `bt_enable()`. The central will now generate a new identity address. 3. Connect the two devices. 4. Re-establish encryption. Now the central will try to use the previously used keys. The procedure will fail because the peripheral does not have any keys associated with the new central address. The API documentation is updated accordingly. Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
9bd0e01
to
a8ae1bf
Compare
Sorry for the last pushes. I forgot to include the change in the prj.conf which I had locally |