Skip to content

Bluetooth: host: Add RPA in directed advertisement support #14984

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

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

joerchan
Copy link
Collaborator

In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.

Fixes #14743

Signed-off-by: Joakim Andersson [email protected]

if (IS_ENABLED(CONFIG_BT_SMP) &&
!IS_ENABLED(CONFIG_BT_PRIVACY) &&
BT_FEAT_LE_PRIVACY(bt_dev.le.features) &&
param->options & BT_LE_ADV_OPT_DIR_ADDR_RPA) {
Copy link
Member

Choose a reason for hiding this comment

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

put parentheses around (foo & bar) to make it clear that you didn't intend to use &&

#define ID_SIZE_MAX sizeof(bt_dev.irk)
#else
#define ID_SIZE_MAX sizeof(bt_dev.id_addr)
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem related, and it was actually removed by one of my own PRs recently.

@codecov-io
Copy link

codecov-io commented Mar 28, 2019

Codecov Report

Merging #14984 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14984      +/-   ##
==========================================
+ Coverage   52.92%   52.93%   +0.01%     
==========================================
  Files         309      309              
  Lines       45268    45267       -1     
  Branches    10451    10451              
==========================================
+ Hits        23956    23960       +4     
+ Misses      16544    16542       -2     
+ Partials     4768     4765       -3
Impacted Files Coverage Δ
include/bluetooth/hci.h 77.77% <ø> (ø) ⬆️
include/bluetooth/bluetooth.h 31.57% <ø> (ø) ⬆️
subsys/bluetooth/host/hci_core.c 44.02% <100%> (-0.04%) ⬇️
subsys/testsuite/ztest/src/ztest.c 72.72% <0%> (+4.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e81cbe...1245d12. Read the comment docs.

@jhedberg
Copy link
Member

jhedberg commented Apr 1, 2019

There's something I don't understand here. The HCI spec says the following about values 0x02 and 0x03 for the Own_Address_Type parameter:
"
0x02 Controller generates the Resolvable Private Address based on the local IRK from the resolving list. If the resolving list contains no matching entry, use the public address.

0x03 Controller generates the Resolvable Private Address based on the local IRK from the resolving list. If the resolving list contains no matching entry, use the random address from LE_Set_Advertising_Set_Random_Address.
"

Now, as you say we don't have a local IRK, so based on the above our behaviour should be exactly the same as if 0x00 or 0x01 would have been given, right? So why do we go through the trouble to say 0x02 or 0x03 when we know the controller will fall back to just normal public/random address?

Another thing that's bothering me is that it should be abundantly clear what API features are workarounds for broken devices (which seems to be the case here - please correct me if I'm wrong), however it's not at all clear from the public API additions. To me the text you've added in the API sounds like this is normal behaviour for privacy-enabled centrals. Am I misunderstanding something here?

@jhedberg jhedberg requested review from cvinayak and carlescufi April 1, 2019 10:31
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

Looks good, just doc issues

* supports address resolution of directed advertisement.
* It is the responsibility of the application to check that the remote
* device supports address resolution of directed advertisements by
* reading it's Central Address Resolution characteristic.
Copy link
Member

Choose a reason for hiding this comment

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

*its

Copy link
Member

Choose a reason for hiding this comment

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

@joerchan this doesn't seem to be fixed yet?


/** Enable use of Private Resolvable Address in directed advertisements
* when CONFIG_BT_PRIVACY is not enabled.
* This is required if the remote device is privacy enabled and
Copy link
Member

Choose a reason for hiding this comment

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

privacy-enabled

@@ -277,6 +277,16 @@ enum {
* bt_conn_create_slave_le().
*/
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4),

/** Enable use of Private Resolvable Address in directed advertisements
Copy link
Member

@carlescufi carlescufi Apr 1, 2019

Choose a reason for hiding this comment

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

*Resolvable Private Address (RPA)
Please specify that this only affects TargetA and not AdvA

@jhedberg
Copy link
Member

jhedberg commented Apr 1, 2019

@joerchan for the record, @carlescufi helped clarify the situation with own_addr_type and the peer_addr being linked even when we don't have a local IRK. I.e. 0x02/0x03 is not quite the same as 0x00/0x01 when we don't have an IRK ourselves. The requested clarifications by @carlescufi are helpful in this regard.

@joerchan joerchan force-pushed the adv_dir_rpa_support branch 2 times, most recently from 24fe883 to f96e87f Compare April 2, 2019 10:10
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks!

Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

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

Besides the typo that's not yet fixed this PR is fine with me

* supports address resolution of directed advertisement.
* It is the responsibility of the application to check that the remote
* device supports address resolution of directed advertisements by
* reading it's Central Address Resolution characteristic.
Copy link
Member

Choose a reason for hiding this comment

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

@joerchan this doesn't seem to be fixed yet?

In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.

Fixes zephyrproject-rtos#14743

Signed-off-by: Joakim Andersson <[email protected]>
@joerchan joerchan force-pushed the adv_dir_rpa_support branch from f96e87f to cead2e8 Compare April 2, 2019 10:42
@carlescufi carlescufi merged commit 710adac into zephyrproject-rtos:master Apr 2, 2019
@joerchan joerchan deleted the adv_dir_rpa_support branch September 24, 2019 11:37
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.

4 participants