-
Notifications
You must be signed in to change notification settings - Fork 3k
BLE: Security Manager traces #14118
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: Security Manager traces #14118
Conversation
to_string(iocaps), | ||
passkey_str(passkey), | ||
to_string(signing), | ||
db_path |
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.
it's a string, though I understand it can be null nevermind it's traced later
if (!_db) { | ||
tr_error("Failure, DB not initialized"); | ||
return BLE_ERROR_INITIALIZATION_INCOMPLETE; | ||
} |
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.
line 349 can fail without trace if _pal.set_csrk doesn't log traces
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.
But it will log trace, generaly, when the step is error = operation; if (error) { return error; }
We can assume (in this context) that operation will trace the error and details of the call.
I don't want to trace errors twice if it doesn't add meaningful information.
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.
yeah, as long as tracing is also added to pal
identity ? identity->identity_address_is_public : false | ||
); | ||
} else { | ||
tr_warning("Event handler removing while retrieving peer ID address"); |
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.
tr_warning("Event handler removing while retrieving peer ID address"); | |
tr_warning("Event handler removed while retrieving peer ID address"); |
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
if (cb->encryption_requested) { | ||
tr_error("Failure, encryption already requested"); |
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.
wouldn't class it as an error, since it's already pending you will actually get what you wnted
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.
actually no, you could ask for something more
@@ -537,18 +750,21 @@ ble_error_t SecurityManager::enableSigning( | |||
cb->db_entry | |||
); | |||
} else { | |||
tr_info("CSRK not available, pair to acquire it"); |
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.
tr_info("CSRK not available, pair to acquire it"); | |
tr_info("CSRK not available, pairing to acquire it"); |
otherwise it implies user action was needed
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.
actually if you're slave you can't force that so maybe the trace should be in the if statement where the role is known
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry); | ||
if (!flags) { | ||
tr_error("Failed to retrieve link encryption, empty distribution flags for %d", connection); |
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.
now I think about it, this can't ever happen, if entry exists it contains flags
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.
It is present in many places, it can happen if the database is corrupted. I wonder if we shouldn't check it when it is loaded then assume it is consistent.
@@ -613,30 +835,38 @@ ble_error_t SecurityManager::setLinkEncryption( | |||
link_encryption_t encryption | |||
) | |||
{ | |||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE; | |||
tr_info("Set %d encryption to %s", connection, to_string(encryption)); |
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.
The problem with logs that are only meaningful in pairs is that tracing may be broken up by other traces and becomes hard to read when the meaning of a line depends on a line potentially N lines lower and you will not know if it's there or which statement it links to.
I think each trace should be self contained.
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.
In the case of an unfiltered log, I think you make a good point. However, if you filter the log by trace group, the stream of traces should be clearer.
return BLE_ERROR_INVALID_PARAM; | ||
} | ||
|
||
eventHandler->linkEncryptionResult(connection, current_encryption); | ||
if (eventHandler) { |
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.
nice catch, maybe worth a separate commit
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.
Very comprehensive. I have my doubts about the context sensitive traces approach.
I don't like tracing whose interpretations relies on more than one line, lines can be broken up and then you can't tell if an action completed correctly or not because even if there is a error trace then you might connect it to the wrong trace line.
Exception are OK, like for example it doesn't matter what causes the "DB not initialised" trace, because it's a global db so it just means it's not there, doesn't matter what caused the discovery of it being missing.
- Prefix with Connection <id> - when appropriate. - Display parameters after `:`. - If multiple parameters should be displayed name then and print the value after =. They are separated by a `,`.
@paul-szczepanek-arm @noonfom I have updated the PR and it is ready for a more formal review. Here's some logs to see the end result: |
Only the first 8 bytes were generated from the stack.
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
Summary of changes
Traces added to Bluetooth Security Manager.
Documentation
Pull request type
Test results
Reviewers