Skip to content
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: Ignore connections from same peer #32700

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

wopu-ot
Copy link
Collaborator

@wopu-ot wopu-ot commented Feb 26, 2021

Ignore connection indications from peers that are already
connected. This is to bring the behavior of the controller in
accordance with [5.2, Vol 6, Part B, 4.5 Connection state]:
"If an advertiser receives a connection request from an initiator it
is already connected to, it shall ignore that request."

Signed-off-by: Wolfgang Puffitsch [email protected]

Fixes #26172

Rename the peer's address in the advertising set struct from `id_addr`
to `peer_addr` to clarify what the address refers to.

Signed-off-by: Wolfgang Puffitsch <[email protected]>
Comment on lines 375 to 382
config BT_CTLR_IGNORE_SAME_PEER_CONN
bool "Ignore connection requests from same peer"
default y
help
Ignored connection requests from the same peer. While the
Bluetooth specification does not allow multiple connections
with the same peer, allowing such connections is useful
while debugging multiple connections.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the spec specifies a shall for this, why is it a Kconfig? Wouldn't disabling this cause the stack to be non-compliant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was suggested by @carlescufi #26172 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Then I would suggest only allowing it to be turned on for TEST/DEBUG builds, e.g. by only allowing it be be n if e.g. BT_TESTING is enabled.

I don't think it's a good idea to intentionally allowing a non-spec compliant build without some sort of warning or making sure that whoever disables this is aware of the consequences.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could make it dependent on BT_CTLR_ADVANCED_FEATURES, though I believe I would have to flip the polarity (...ALLOW... instead of ...IGNORE... and !defined instead of defined) to get the correct behavior if the former is not defined.

Copy link
Collaborator

@Thalley Thalley Mar 8, 2021

Choose a reason for hiding this comment

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

Alternatively we could add similar warnings to disabling this as we have when e.g. we enable SMP debug keys. See #26186

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved the user-controller flag it under BT_CTLR_ADVANCED_FEATURES and added a WARNING to the description. I also made the configuration now dependent on having more than one connection to not punish implementations that allow only a single connection anyway.

subsys/bluetooth/controller/ll_sw/ull_filter.c Outdated Show resolved Hide resolved
subsys/bluetooth/controller/ll_sw/ull_adv.c Outdated Show resolved Hide resolved
Ignore connection indications from peers that are already
connected. This is to bring the behavior of the controller in
accordance with [5.2, Vol 6, Part B, 4.5 Connection state]:
"If an advertiser receives a connection request from an initiator it
is already connected to, it shall ignore that request."

Signed-off-by: Wolfgang Puffitsch <[email protected]>
Comment on lines +487 to +488
WARNING: This option enables behavior that violates the Bluetooth
specification.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like @carlescufi input on whether this is enough, or if we also should add build warnings like was done for other such configurations in #26186

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would like @carlescufi input on whether this is enough, or if we also should add build warnings like was done for other such configurations in #26186

@carlescufi What is your take in this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@wopu-ot Is this something that is critical to get in? I can mark it as approved, and then we can consider adding additional warnings (if needed) afterwards in a separate PR.

Copy link
Collaborator

@erbr-ot erbr-ot left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

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

quick-ack.

@nashif nashif merged commit 010c5c2 into zephyrproject-rtos:master Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zephyr Master/Slave not conforming with Core Spec. 5.2 connection policies
5 participants