Bluetooth: hci_sync: Resume adv with no RPA when active scan
authorZhengping Jiang <jiangzp@google.com>
Wed, 22 Feb 2023 00:17:56 +0000 (16:17 -0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 22 Mar 2023 23:05:55 +0000 (16:05 -0700)
commit3c44a431d62bf4a20d7b901f98266ae3f4676d48
tree41684edbba46245d19d3470b3a0aefe275ac7713
parentbb765a743377d46d8da8e7f7e5128022504741b9
Bluetooth: hci_sync: Resume adv with no RPA when active scan

The address resolution should be disabled during the active scan,
so all the advertisements can reach the host. The advertising
has to be paused before disabling the address resolution,
because the advertising will prevent any changes to the resolving
list and the address resolution status. Skipping this will cause
the hci error and the discovery failure.

According to the bluetooth specification:
"7.8.44 LE Set Address Resolution Enable command

This command shall not be used when:
- Advertising (other than periodic advertising) is enabled,
- Scanning is enabled, or
- an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or
  HCI_LE_Periodic_Advertising_Create_Sync command is outstanding."

If the host is using RPA, the controller needs to generate RPA for
the advertising, so the advertising must remain paused during the
active scan.

If the host is not using RPA, the advertising can be resumed after
disabling the address resolution.

Fixes: 9afc675edeeb ("Bluetooth: hci_sync: allow advertise when scan without RPA")
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_sync.c