aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaganath Kanakkassery <jaganath.k.os@gmail.com>2018-07-19 07:39:45 -0400
committerMarcel Holtmann <marcel@holtmann.org>2018-07-30 07:44:53 -0400
commita73c046a2869048430c332a871a5b169f192c6c3 (patch)
tree181d2505299b87573aec081feb32b4f0b9e394ae
parent075e40b79f6d0aa1479701d2dd6dea3b78478d60 (diff)
Bluetooth: Implement Set ADV set random address
This basically sets the random address for the adv instance Random address can be set only if the instance is created which is done in Set ext adv param. Random address and rpa expire timer and flags have been added to adv instance which will be used when the respective instance is scheduled. This introduces a hci_get_random_address() which returns the own address type and random address (rpa or nrpa) based on the instance flags and hdev flags. New function is required since own address type should be known before setting adv params but address can be set only after setting params. < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7 Advertising handle: 0x00 Advertising random address: 3C:8E:56:9B:77:84 (OUI 3C-8E-56) > HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1 Status: Success (0x00) Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/bluetooth/hci.h6
-rw-r--r--include/net/bluetooth/hci_core.h4
-rw-r--r--net/bluetooth/hci_conn.c23
-rw-r--r--net/bluetooth/hci_core.c33
-rw-r--r--net/bluetooth/hci_event.c37
-rw-r--r--net/bluetooth/hci_request.c128
-rw-r--r--net/bluetooth/hci_request.h3
-rw-r--r--net/bluetooth/mgmt.c2
8 files changed, 233 insertions, 3 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index faa2922a69fd..8d348d0d3eea 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1649,6 +1649,12 @@ struct hci_cp_le_set_ext_scan_rsp_data {
1649 1649
1650#define HCI_OP_LE_CLEAR_ADV_SETS 0x203d 1650#define HCI_OP_LE_CLEAR_ADV_SETS 0x203d
1651 1651
1652#define HCI_OP_LE_SET_ADV_SET_RAND_ADDR 0x2035
1653struct hci_cp_le_set_adv_set_rand_addr {
1654 __u8 handle;
1655 bdaddr_t bdaddr;
1656} __packed;
1657
1652/* ---- HCI Events ---- */ 1658/* ---- HCI Events ---- */
1653#define HCI_EV_INQUIRY_COMPLETE 0x01 1659#define HCI_EV_INQUIRY_COMPLETE 0x01
1654 1660
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ad3518303a0c..0db1b9b428b7 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -172,6 +172,9 @@ struct adv_info {
172 __u16 scan_rsp_len; 172 __u16 scan_rsp_len;
173 __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; 173 __u8 scan_rsp_data[HCI_MAX_AD_LENGTH];
174 __s8 tx_power; 174 __s8 tx_power;
175 bdaddr_t random_addr;
176 bool rpa_expired;
177 struct delayed_work rpa_expired_cb;
175}; 178};
176 179
177#define HCI_MAX_ADV_INSTANCES 5 180#define HCI_MAX_ADV_INSTANCES 5
@@ -1113,6 +1116,7 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
1113 u16 scan_rsp_len, u8 *scan_rsp_data, 1116 u16 scan_rsp_len, u8 *scan_rsp_data,
1114 u16 timeout, u16 duration); 1117 u16 timeout, u16 duration);
1115int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance); 1118int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance);
1119void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired);
1116 1120
1117void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 1121void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
1118 1122
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5c37d383caa3..bd4978ce8c45 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -873,6 +873,14 @@ static void hci_req_directed_advertising(struct hci_request *req,
873 873
874 if (ext_adv_capable(hdev)) { 874 if (ext_adv_capable(hdev)) {
875 struct hci_cp_le_set_ext_adv_params cp; 875 struct hci_cp_le_set_ext_adv_params cp;
876 bdaddr_t random_addr;
877
878 /* Set require_privacy to false so that the remote device has a
879 * chance of identifying us.
880 */
881 if (hci_get_random_address(hdev, false, conn_use_rpa(conn), NULL,
882 &own_addr_type, &random_addr) < 0)
883 return;
876 884
877 memset(&cp, 0, sizeof(cp)); 885 memset(&cp, 0, sizeof(cp));
878 886
@@ -889,6 +897,21 @@ static void hci_req_directed_advertising(struct hci_request *req,
889 897
890 hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp); 898 hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
891 899
900 if (own_addr_type == ADDR_LE_DEV_RANDOM &&
901 bacmp(&random_addr, BDADDR_ANY) &&
902 bacmp(&random_addr, &hdev->random_addr)) {
903 struct hci_cp_le_set_adv_set_rand_addr cp;
904
905 memset(&cp, 0, sizeof(cp));
906
907 cp.handle = 0;
908 bacpy(&cp.bdaddr, &random_addr);
909
910 hci_req_add(req,
911 HCI_OP_LE_SET_ADV_SET_RAND_ADDR,
912 sizeof(cp), &cp);
913 }
914
892 __hci_req_enable_ext_advertising(req); 915 __hci_req_enable_ext_advertising(req);
893 } else { 916 } else {
894 struct hci_cp_le_set_adv_param cp; 917 struct hci_cp_le_set_adv_param cp;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 944d4fedc317..840e8fd89fa5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1471,6 +1471,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
1471 if (!ret) { 1471 if (!ret) {
1472 hci_dev_hold(hdev); 1472 hci_dev_hold(hdev);
1473 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); 1473 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
1474 hci_adv_instances_set_rpa_expired(hdev, true);
1474 set_bit(HCI_UP, &hdev->flags); 1475 set_bit(HCI_UP, &hdev->flags);
1475 hci_sock_dev_event(hdev, HCI_DEV_UP); 1476 hci_sock_dev_event(hdev, HCI_DEV_UP);
1476 hci_leds_update_powered(hdev, true); 1477 hci_leds_update_powered(hdev, true);
@@ -1626,9 +1627,15 @@ int hci_dev_do_close(struct hci_dev *hdev)
1626 if (hci_dev_test_and_clear_flag(hdev, HCI_SERVICE_CACHE)) 1627 if (hci_dev_test_and_clear_flag(hdev, HCI_SERVICE_CACHE))
1627 cancel_delayed_work(&hdev->service_cache); 1628 cancel_delayed_work(&hdev->service_cache);
1628 1629
1629 if (hci_dev_test_flag(hdev, HCI_MGMT)) 1630 if (hci_dev_test_flag(hdev, HCI_MGMT)) {
1631 struct adv_info *adv_instance;
1632
1630 cancel_delayed_work_sync(&hdev->rpa_expired); 1633 cancel_delayed_work_sync(&hdev->rpa_expired);
1631 1634
1635 list_for_each_entry(adv_instance, &hdev->adv_instances, list)
1636 cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
1637 }
1638
1632 /* Avoid potential lockdep warnings from the *_flush() calls by 1639 /* Avoid potential lockdep warnings from the *_flush() calls by
1633 * ensuring the workqueue is empty up front. 1640 * ensuring the workqueue is empty up front.
1634 */ 1641 */
@@ -2704,6 +2711,8 @@ int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance)
2704 hdev->cur_adv_instance = 0x00; 2711 hdev->cur_adv_instance = 0x00;
2705 } 2712 }
2706 2713
2714 cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
2715
2707 list_del(&adv_instance->list); 2716 list_del(&adv_instance->list);
2708 kfree(adv_instance); 2717 kfree(adv_instance);
2709 2718
@@ -2712,6 +2721,14 @@ int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance)
2712 return 0; 2721 return 0;
2713} 2722}
2714 2723
2724void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired)
2725{
2726 struct adv_info *adv_instance, *n;
2727
2728 list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list)
2729 adv_instance->rpa_expired = rpa_expired;
2730}
2731
2715/* This function requires the caller holds hdev->lock */ 2732/* This function requires the caller holds hdev->lock */
2716void hci_adv_instances_clear(struct hci_dev *hdev) 2733void hci_adv_instances_clear(struct hci_dev *hdev)
2717{ 2734{
@@ -2723,6 +2740,7 @@ void hci_adv_instances_clear(struct hci_dev *hdev)
2723 } 2740 }
2724 2741
2725 list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) { 2742 list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) {
2743 cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
2726 list_del(&adv_instance->list); 2744 list_del(&adv_instance->list);
2727 kfree(adv_instance); 2745 kfree(adv_instance);
2728 } 2746 }
@@ -2731,6 +2749,16 @@ void hci_adv_instances_clear(struct hci_dev *hdev)
2731 hdev->cur_adv_instance = 0x00; 2749 hdev->cur_adv_instance = 0x00;
2732} 2750}
2733 2751
2752static void adv_instance_rpa_expired(struct work_struct *work)
2753{
2754 struct adv_info *adv_instance = container_of(work, struct adv_info,
2755 rpa_expired_cb.work);
2756
2757 BT_DBG("");
2758
2759 adv_instance->rpa_expired = true;
2760}
2761
2734/* This function requires the caller holds hdev->lock */ 2762/* This function requires the caller holds hdev->lock */
2735int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, 2763int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
2736 u16 adv_data_len, u8 *adv_data, 2764 u16 adv_data_len, u8 *adv_data,
@@ -2781,6 +2809,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
2781 2809
2782 adv_instance->tx_power = HCI_TX_POWER_INVALID; 2810 adv_instance->tx_power = HCI_TX_POWER_INVALID;
2783 2811
2812 INIT_DELAYED_WORK(&adv_instance->rpa_expired_cb,
2813 adv_instance_rpa_expired);
2814
2784 BT_DBG("%s for %dMR", hdev->name, instance); 2815 BT_DBG("%s for %dMR", hdev->name, instance);
2785 2816
2786 return 0; 2817 return 0;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index a78d1dd2f57b..392c9d8febd0 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1064,6 +1064,35 @@ static void hci_cc_le_set_default_phy(struct hci_dev *hdev, struct sk_buff *skb)
1064 hci_dev_unlock(hdev); 1064 hci_dev_unlock(hdev);
1065} 1065}
1066 1066
1067static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev,
1068 struct sk_buff *skb)
1069{
1070 __u8 status = *((__u8 *) skb->data);
1071 struct hci_cp_le_set_adv_set_rand_addr *cp;
1072 struct adv_info *adv_instance;
1073
1074 if (status)
1075 return;
1076
1077 cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_SET_RAND_ADDR);
1078 if (!cp)
1079 return;
1080
1081 hci_dev_lock(hdev);
1082
1083 if (!hdev->cur_adv_instance) {
1084 /* Store in hdev for instance 0 (Set adv and Directed advs) */
1085 bacpy(&hdev->random_addr, &cp->bdaddr);
1086 } else {
1087 adv_instance = hci_find_adv_instance(hdev,
1088 hdev->cur_adv_instance);
1089 if (adv_instance)
1090 bacpy(&adv_instance->random_addr, &cp->bdaddr);
1091 }
1092
1093 hci_dev_unlock(hdev);
1094}
1095
1067static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) 1096static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
1068{ 1097{
1069 __u8 *sent, status = *((__u8 *) skb->data); 1098 __u8 *sent, status = *((__u8 *) skb->data);
@@ -2830,8 +2859,10 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
2830 /* We should disregard the current RPA and generate a new one 2859 /* We should disregard the current RPA and generate a new one
2831 * whenever the encryption procedure fails. 2860 * whenever the encryption procedure fails.
2832 */ 2861 */
2833 if (ev->status && conn->type == LE_LINK) 2862 if (ev->status && conn->type == LE_LINK) {
2834 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); 2863 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
2864 hci_adv_instances_set_rpa_expired(hdev, true);
2865 }
2835 2866
2836 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags); 2867 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
2837 2868
@@ -3283,6 +3314,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
3283 hci_cc_le_set_ext_adv_enable(hdev, skb); 3314 hci_cc_le_set_ext_adv_enable(hdev, skb);
3284 break; 3315 break;
3285 3316
3317 case HCI_OP_LE_SET_ADV_SET_RAND_ADDR:
3318 hci_cc_le_set_adv_set_random_addr(hdev, skb);
3319 break;
3320
3286 default: 3321 default:
3287 BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode); 3322 BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode);
3288 break; 3323 break;
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 96e1e05a92c3..c72fd9202666 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1440,6 +1440,87 @@ unlock:
1440 hci_dev_unlock(hdev); 1440 hci_dev_unlock(hdev);
1441} 1441}
1442 1442
1443int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
1444 bool use_rpa, struct adv_info *adv_instance,
1445 u8 *own_addr_type, bdaddr_t *rand_addr)
1446{
1447 int err;
1448
1449 bacpy(rand_addr, BDADDR_ANY);
1450
1451 /* If privacy is enabled use a resolvable private address. If
1452 * current RPA has expired then generate a new one.
1453 */
1454 if (use_rpa) {
1455 int to;
1456
1457 *own_addr_type = ADDR_LE_DEV_RANDOM;
1458
1459 if (adv_instance) {
1460 if (!adv_instance->rpa_expired &&
1461 !bacmp(&adv_instance->random_addr, &hdev->rpa))
1462 return 0;
1463
1464 adv_instance->rpa_expired = false;
1465 } else {
1466 if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) &&
1467 !bacmp(&hdev->random_addr, &hdev->rpa))
1468 return 0;
1469 }
1470
1471 err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
1472 if (err < 0) {
1473 BT_ERR("%s failed to generate new RPA", hdev->name);
1474 return err;
1475 }
1476
1477 bacpy(rand_addr, &hdev->rpa);
1478
1479 to = msecs_to_jiffies(hdev->rpa_timeout * 1000);
1480 if (adv_instance)
1481 queue_delayed_work(hdev->workqueue,
1482 &adv_instance->rpa_expired_cb, to);
1483 else
1484 queue_delayed_work(hdev->workqueue,
1485 &hdev->rpa_expired, to);
1486
1487 return 0;
1488 }
1489
1490 /* In case of required privacy without resolvable private address,
1491 * use an non-resolvable private address. This is useful for
1492 * non-connectable advertising.
1493 */
1494 if (require_privacy) {
1495 bdaddr_t nrpa;
1496
1497 while (true) {
1498 /* The non-resolvable private address is generated
1499 * from random six bytes with the two most significant
1500 * bits cleared.
1501 */
1502 get_random_bytes(&nrpa, 6);
1503 nrpa.b[5] &= 0x3f;
1504
1505 /* The non-resolvable private address shall not be
1506 * equal to the public address.
1507 */
1508 if (bacmp(&hdev->bdaddr, &nrpa))
1509 break;
1510 }
1511
1512 *own_addr_type = ADDR_LE_DEV_RANDOM;
1513 bacpy(rand_addr, &nrpa);
1514
1515 return 0;
1516 }
1517
1518 /* No privacy so use a public address. */
1519 *own_addr_type = ADDR_LE_DEV_PUBLIC;
1520
1521 return 0;
1522}
1523
1443void __hci_req_clear_ext_adv_sets(struct hci_request *req) 1524void __hci_req_clear_ext_adv_sets(struct hci_request *req)
1444{ 1525{
1445 hci_req_add(req, HCI_OP_LE_CLEAR_ADV_SETS, 0, NULL); 1526 hci_req_add(req, HCI_OP_LE_CLEAR_ADV_SETS, 0, NULL);
@@ -1451,9 +1532,21 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1451 struct hci_dev *hdev = req->hdev; 1532 struct hci_dev *hdev = req->hdev;
1452 bool connectable; 1533 bool connectable;
1453 u32 flags; 1534 u32 flags;
1535 bdaddr_t random_addr;
1536 u8 own_addr_type;
1537 int err;
1538 struct adv_info *adv_instance;
1454 /* In ext adv set param interval is 3 octets */ 1539 /* In ext adv set param interval is 3 octets */
1455 const u8 adv_interval[3] = { 0x00, 0x08, 0x00 }; 1540 const u8 adv_interval[3] = { 0x00, 0x08, 0x00 };
1456 1541
1542 if (instance > 0) {
1543 adv_instance = hci_find_adv_instance(hdev, instance);
1544 if (!adv_instance)
1545 return -EINVAL;
1546 } else {
1547 adv_instance = NULL;
1548 }
1549
1457 flags = get_adv_instance_flags(hdev, instance); 1550 flags = get_adv_instance_flags(hdev, instance);
1458 1551
1459 /* If the "connectable" instance flag was not set, then choose between 1552 /* If the "connectable" instance flag was not set, then choose between
@@ -1465,6 +1558,16 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1465 if (!is_advertising_allowed(hdev, connectable)) 1558 if (!is_advertising_allowed(hdev, connectable))
1466 return -EPERM; 1559 return -EPERM;
1467 1560
1561 /* Set require_privacy to true only when non-connectable
1562 * advertising is used. In that case it is fine to use a
1563 * non-resolvable private address.
1564 */
1565 err = hci_get_random_address(hdev, !connectable,
1566 adv_use_rpa(hdev, flags), adv_instance,
1567 &own_addr_type, &random_addr);
1568 if (err < 0)
1569 return err;
1570
1468 memset(&cp, 0, sizeof(cp)); 1571 memset(&cp, 0, sizeof(cp));
1469 1572
1470 memcpy(cp.min_interval, adv_interval, sizeof(cp.min_interval)); 1573 memcpy(cp.min_interval, adv_interval, sizeof(cp.min_interval));
@@ -1477,7 +1580,7 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1477 else 1580 else
1478 cp.evt_properties = cpu_to_le16(LE_LEGACY_NONCONN_IND); 1581 cp.evt_properties = cpu_to_le16(LE_LEGACY_NONCONN_IND);
1479 1582
1480 cp.own_addr_type = BDADDR_LE_PUBLIC; 1583 cp.own_addr_type = own_addr_type;
1481 cp.channel_map = hdev->le_adv_channel_map; 1584 cp.channel_map = hdev->le_adv_channel_map;
1482 cp.tx_power = 127; 1585 cp.tx_power = 127;
1483 cp.primary_phy = HCI_ADV_PHY_1M; 1586 cp.primary_phy = HCI_ADV_PHY_1M;
@@ -1486,6 +1589,29 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1486 1589
1487 hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp); 1590 hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
1488 1591
1592 if (own_addr_type == ADDR_LE_DEV_RANDOM &&
1593 bacmp(&random_addr, BDADDR_ANY)) {
1594 struct hci_cp_le_set_adv_set_rand_addr cp;
1595
1596 /* Check if random address need to be updated */
1597 if (adv_instance) {
1598 if (!bacmp(&random_addr, &adv_instance->random_addr))
1599 return 0;
1600 } else {
1601 if (!bacmp(&random_addr, &hdev->random_addr))
1602 return 0;
1603 }
1604
1605 memset(&cp, 0, sizeof(cp));
1606
1607 cp.handle = 0;
1608 bacpy(&cp.bdaddr, &random_addr);
1609
1610 hci_req_add(req,
1611 HCI_OP_LE_SET_ADV_SET_RAND_ADDR,
1612 sizeof(cp), &cp);
1613 }
1614
1489 return 0; 1615 return 0;
1490} 1616}
1491 1617
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
index 2451861bb4f8..692cc8b13368 100644
--- a/net/bluetooth/hci_request.h
+++ b/net/bluetooth/hci_request.h
@@ -84,6 +84,9 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance);
84int __hci_req_start_ext_adv(struct hci_request *req, u8 instance); 84int __hci_req_start_ext_adv(struct hci_request *req, u8 instance);
85void __hci_req_enable_ext_advertising(struct hci_request *req); 85void __hci_req_enable_ext_advertising(struct hci_request *req);
86void __hci_req_clear_ext_adv_sets(struct hci_request *req); 86void __hci_req_clear_ext_adv_sets(struct hci_request *req);
87int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
88 bool use_rpa, struct adv_info *adv_instance,
89 u8 *own_addr_type, bdaddr_t *rand_addr);
87 90
88void __hci_req_update_class(struct hci_request *req); 91void __hci_req_update_class(struct hci_request *req);
89 92
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c283f0364c0f..949986727019 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4972,6 +4972,7 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
4972 changed = !hci_dev_test_and_set_flag(hdev, HCI_PRIVACY); 4972 changed = !hci_dev_test_and_set_flag(hdev, HCI_PRIVACY);
4973 memcpy(hdev->irk, cp->irk, sizeof(hdev->irk)); 4973 memcpy(hdev->irk, cp->irk, sizeof(hdev->irk));
4974 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED); 4974 hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
4975 hci_adv_instances_set_rpa_expired(hdev, true);
4975 if (cp->privacy == 0x02) 4976 if (cp->privacy == 0x02)
4976 hci_dev_set_flag(hdev, HCI_LIMITED_PRIVACY); 4977 hci_dev_set_flag(hdev, HCI_LIMITED_PRIVACY);
4977 else 4978 else
@@ -4980,6 +4981,7 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
4980 changed = hci_dev_test_and_clear_flag(hdev, HCI_PRIVACY); 4981 changed = hci_dev_test_and_clear_flag(hdev, HCI_PRIVACY);
4981 memset(hdev->irk, 0, sizeof(hdev->irk)); 4982 memset(hdev->irk, 0, sizeof(hdev->irk));
4982 hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); 4983 hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED);
4984 hci_adv_instances_set_rpa_expired(hdev, false);
4983 hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY); 4985 hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY);
4984 } 4986 }
4985 4987