Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ce194c4 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann
Browse files

Bluetooth: Use real advertising state to random address update decision



Now that we have a flag for tracking the real advertising state we
should use that to determine whether it's safe to update the random
address or not. The couple of places that were clearing the flag due to
a pending request need to be updated too.

Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent c93bd150
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -671,12 +671,12 @@ static void hci_req_directed_advertising(struct hci_request *req,
	enable = 0x00;
	enable = 0x00;
	hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
	hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);


	/* Clear the HCI_ADVERTISING bit temporarily so that the
	/* Clear the HCI_LE_ADV bit temporarily so that the
	 * hci_update_random_address knows that it's safe to go ahead
	 * hci_update_random_address knows that it's safe to go ahead
	 * and write a new random address. The flag will be set back on
	 * and write a new random address. The flag will be set back on
	 * as soon as the SET_ADV_ENABLE HCI command completes.
	 * as soon as the SET_ADV_ENABLE HCI command completes.
	 */
	 */
	clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
	clear_bit(HCI_LE_ADV, &hdev->dev_flags);


	/* Set require_privacy to false so that the remote device has a
	/* Set require_privacy to false so that the remote device has a
	 * chance of identifying us.
	 * chance of identifying us.
+1 −1
Original line number Original line Diff line number Diff line
@@ -3746,7 +3746,7 @@ static void set_random_addr(struct hci_request *req, bdaddr_t *rpa)
	 * In this kind of scenario skip the update and let the random
	 * In this kind of scenario skip the update and let the random
	 * address be updated at the next cycle.
	 * address be updated at the next cycle.
	 */
	 */
	if (test_bit(HCI_ADVERTISING, &hdev->dev_flags) ||
	if (test_bit(HCI_LE_ADV, &hdev->dev_flags) ||
	    hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) {
	    hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) {
		BT_DBG("Deferring random address update");
		BT_DBG("Deferring random address update");
		return;
		return;
+2 −2
Original line number Original line Diff line number Diff line
@@ -1046,12 +1046,12 @@ static void enable_advertising(struct hci_request *req)
	u8 own_addr_type, enable = 0x01;
	u8 own_addr_type, enable = 0x01;
	bool connectable;
	bool connectable;


	/* Clear the HCI_ADVERTISING bit temporarily so that the
	/* Clear the HCI_LE_ADV bit temporarily so that the
	 * hci_update_random_address knows that it's safe to go ahead
	 * hci_update_random_address knows that it's safe to go ahead
	 * and write a new random address. The flag will be set back on
	 * and write a new random address. The flag will be set back on
	 * as soon as the SET_ADV_ENABLE HCI command completes.
	 * as soon as the SET_ADV_ENABLE HCI command completes.
	 */
	 */
	clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
	clear_bit(HCI_LE_ADV, &hdev->dev_flags);


	connectable = get_connectable(hdev);
	connectable = get_connectable(hdev);