-
Notifications
You must be signed in to change notification settings - Fork 7k
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: Controller: Fix div-by-zero with BT_CONN_PARAM_ANY #84154
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,7 +235,14 @@ static void lp_comm_tx(struct ll_conn *conn, struct proc_ctx *ctx) | |
* NOTE: As the supervision timeout is at most 32s the normal procedure response | ||
* timeout of 40s will never come into play for the ACL Termination procedure. | ||
*/ | ||
const uint32_t conn_interval_us = conn->lll.interval * CONN_INT_UNIT_US; | ||
uint32_t conn_interval_us; | ||
|
||
if (conn->lll.interval >= BT_HCI_LE_INTERVAL_MIN) { | ||
conn_interval_us = conn->lll.interval * CONN_INT_UNIT_US; | ||
} else { | ||
conn_interval_us = (conn->lll.interval + 1U) * CONN_LOW_LAT_INT_UNIT_US; | ||
} | ||
Comment on lines
+242
to
+244
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should a comment stating why/how/when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These change are base dependencies for now adopted Frame Space Update procedure in PR: #82324 I am hoping the non-standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In any case, this code is non-standard (not spec-compliant) and pretty undocumented. We should add comment stating why this is here, and why it's |
||
|
||
const uint16_t sto_reload = RADIO_CONN_EVENTS( | ||
(conn->supervision_timeout * 10U * 1000U), | ||
conn_interval_us); | ||
|
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.
When can
conn->lll.interval
end up being< BT_HCI_LE_INTERVAL_MIN
?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.
CONFIG_BT_CONN_PARAM_ANY=y
allows connection interval values less thanBT_HCI_LE_INTERVAL_MIN
and greater thanBT_HCI_LE_INTERVAL_MAX
allowing some vendor implementation to use proprietary connection interval timings represented outside the defined min/max. In the Zephyr Controller, values 0 to 5 are used to stress the scheduling design/implementation for overlapping connection role under babblesim CI testing; a value of 1 respresents 1 ms interval (where in 0 is 500 us, and 5 is 3 ms).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.
So
conn->lll.interval == 0
is a valid value?I count 15 places wher
conn->lll.interval
is multiplied by something else, making all those expression end up as 0. While I believe this PR is fixing one such specific case for a good reason, I have my doubts that this is a proper solution.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.
Other places are related to Connected ISO, and these non-standard values use (CONFIG_BT_CONN_PARAM_ANY=y) would likely misbehave. Hence, not worth the effort to have added branching in Connected ISO use cases.
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.
There are several places in non-ISO that also multiply by
conn->lll.interval
.Missed this question I think :)
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.
Those are in connection establishment implementation, initiator/central and peripheral connection establishment. Support for initial connection establishment with these non-standard value in not supported/planned or covered in bsim test either. This will have to be a separate task outside the scope of this PR.
yes, Host permits a value of
0
as connection interval whenCONFIG_BT_CONN_PARAM_ANY=y
, but is not supported in Zephyr Controller for connection establishment, only supporting it in LL Connection Update and LL Connection Parameter Request Procedures, refer to c3f557cThere 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.
Will you create a GH issue or something for it then? If we allow
conn->lll.interval == 0
then that seems to be a fairly high risk of being misused as it is not allowed to be0
by the core spec.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.
Seems its easier to fix the occurrences to help aid future feature development; putting PR back to draft until I get around to fixing it and updating a bsim coverage.