-
Notifications
You must be signed in to change notification settings - Fork 3k
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
BLE: Manual BLE security manager db synchronisation #14824
Conversation
dcb361f
to
c9d0ff8
Compare
@paul-szczepanek-arm, thank you for your changes. |
@@ -501,11 +501,29 @@ class SecurityManager | |||
* Normally all bonding information is lost when device is reset, this requests that the stack | |||
* attempts to save the information and reload it during initialisation. This is not guaranteed. | |||
* | |||
* @note This option is itself saved together with bonding data. When data is read after reset, | |||
* the state of this option decides if data should be restored. If this option has not been saved |
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.
My read of this is that writeBondingStateToPersistentStorage
is effectively a no-op unless preserveBondingStateOnReset
is set to true before the reset. What's the rationale behind 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.
preserveBondingStateOnReset is an option that affects behaviour after the reset. Maybe I should've called it loadBondingDataFromPersistentStorageAfterReset
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.
Could writeBondingStateToPersistentStorage
implicitly set preserveBondingStateOnReset
? Or is there a reason someone would write the data but not automatically load it after a 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.
That is a good point. If I can't find a good reason by tomorrow I'll add the call.
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.
How do we test this ?
Should we add a command for sync and reset the MCU during the test ?
It is a draft, what is expected to be added to this PR ?
* @note You still need to call preserveBondingStateOnReset(true) before reset happens for data to be | ||
* loaded when it's read. | ||
* | ||
* @note Depending on the driver used to implement the storage solution used this may be a disruptive |
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.
Maybe we could use a less ominous tone and instruct the user to prefer calling this function outside of connection otherwise the connection can drop if storage is the internal flash.
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.
Well, this is what it means. Other operations may be affected not just connections. That's why I used generic phrasing.
@@ -136,7 +136,7 @@ class FileSecurityDb : public SecurityDb { | |||
|
|||
virtual void restore(); | |||
|
|||
virtual void sync(entry_handle_t db_handle); | |||
virtual void sync(entry_handle_t db_handle = invalid_entry_handle); |
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.
What do we gain with the default parameter ? It is an implementation and it won't be called directly by the BLE framework.
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.
So that I don't have to modify existing code.
@@ -200,7 +200,7 @@ class KVStoreSecurityDb : public SecurityDb { | |||
|
|||
virtual void restore(); | |||
|
|||
virtual void sync(entry_handle_t db_handle); | |||
virtual void sync(entry_handle_t db_handle = invalid_entry_handle); |
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.
Same as above
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.
See above.
It will stop being a draft when I verify this :P |
@AGlass0fMilk does this solution look acceptable to you? |
Tested with persistent storage, flushing works so you can sync storage before reset. |
So this essentially adds a new Security Manager API method to manually flush the security DB to non-volatile storage? Does the SM still need to be reset afterwards? I see that as an arbitrary requirement -- why does the SM state need to be reset to simply save the current security database? If this works as you say, I think it's fine. The main goal is to make it clear to users how to save security credentials to NV memory to save them the headache of debugging caching/filesystem-related issues. |
no, you don't need to reset it anymore, the new call causes buffers to flush so your db is good to be restored |
This pull request has automatically been marked as stale because it has had no recent activity. @AGlass0fMilk, @pan-, @ARMmbed/mbed-os-maintainers, @ARMmbed/mbed-os-test, please complete review of the changes to move the PR forward. Thank you for your contributions. |
@AGlass0fMilk does it solve your problem? Please accept in review or let me know what you don't like. |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
Adds new BLE API call to manually attempt to synchronise the security manager DB.
Impact of changes
Migration actions required
Documentation
none
Pull request type
Test results
Reviewers