Skip to content

Commit e413617

Browse files
joerchanjhedberg
authored andcommitted
Bluetooth: Host: Fix duplicate whitelist entries issue
If the whitelist already exists in the controller then the controller should not add the device tot the whitelist and should return success. In that case the counting of entries in the whitelist in the host will be wrong. Remove all whitelist counting in the host, and instead rely on the error reported by the controller for this. The controller should return error if the whitelist is full. The controller should return error if use of whitelist was requested but the whitelist was empty. Signed-off-by: Joakim Andersson <[email protected]>
1 parent 1d25eba commit e413617

File tree

3 files changed

+0
-63
lines changed

3 files changed

+0
-63
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,10 +2053,6 @@ int bt_conn_create_auto_le(const struct bt_le_conn_param *param)
20532053
return -EALREADY;
20542054
}
20552055

2056-
if (!bt_dev.le.wl_entries) {
2057-
return -EINVAL;
2058-
}
2059-
20602056
/* Don't start initiator if we have general discovery procedure. */
20612057
conn = bt_conn_lookup_state_le(NULL, BT_CONN_CONNECT_SCAN);
20622058
if (conn) {

subsys/bluetooth/host/hci_core.c

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,6 @@ static inline void handle_event(u8_t event, struct net_buf *buf,
208208
buf->len, bt_hex(buf->data, buf->len));
209209
}
210210

211-
static inline bool is_wl_empty(void)
212-
{
213-
#if defined(CONFIG_BT_WHITELIST)
214-
return !bt_dev.le.wl_entries;
215-
#else
216-
return true;
217-
#endif /* defined(CONFIG_BT_WHITELIST) */
218-
}
219-
220211
#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
221212
static void report_completed_packet(struct net_buf *buf)
222213
{
@@ -4097,18 +4088,6 @@ static void le_read_resolving_list_size_complete(struct net_buf *buf)
40974088
}
40984089
#endif /* defined(CONFIG_BT_SMP) */
40994090

4100-
#if defined(CONFIG_BT_WHITELIST)
4101-
static void le_read_wl_size_complete(struct net_buf *buf)
4102-
{
4103-
struct bt_hci_rp_le_read_wl_size *rp =
4104-
(struct bt_hci_rp_le_read_wl_size *)buf->data;
4105-
4106-
BT_DBG("Whitelist size %u", rp->wl_size);
4107-
4108-
bt_dev.le.wl_size = rp->wl_size;
4109-
}
4110-
#endif
4111-
41124091
static int common_init(void)
41134092
{
41144093
struct net_buf *rsp;
@@ -4370,17 +4349,6 @@ static int le_init(void)
43704349
}
43714350
#endif
43724351

4373-
#if defined(CONFIG_BT_WHITELIST)
4374-
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_WL_SIZE, NULL,
4375-
&rsp);
4376-
if (err) {
4377-
return err;
4378-
}
4379-
4380-
le_read_wl_size_complete(rsp);
4381-
net_buf_unref(rsp);
4382-
#endif /* defined(CONFIG_BT_WHITELIST) */
4383-
43844352
return le_set_event_mask();
43854353
}
43864354

@@ -5554,13 +5522,6 @@ static bool valid_adv_param(const struct bt_le_adv_param *param, bool dir_adv)
55545522
}
55555523
}
55565524

5557-
if (is_wl_empty() &&
5558-
((param->options & BT_LE_ADV_OPT_FILTER_SCAN_REQ) ||
5559-
(param->options & BT_LE_ADV_OPT_FILTER_CONN))) {
5560-
return false;
5561-
}
5562-
5563-
55645525
if ((param->options & BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY) || !dir_adv) {
55655526
if (param->interval_min > param->interval_max ||
55665527
param->interval_min < 0x0020 ||
@@ -5880,11 +5841,6 @@ static bool valid_le_scan_param(const struct bt_le_scan_param *param)
58805841
return false;
58815842
}
58825843

5883-
if (is_wl_empty() &&
5884-
param->filter_dup & BT_LE_SCAN_FILTER_WHITELIST) {
5885-
return false;
5886-
}
5887-
58885844
if (param->interval < 0x0004 || param->interval > 0x4000) {
58895845
return false;
58905846
}
@@ -5965,10 +5921,6 @@ int bt_le_whitelist_add(const bt_addr_le_t *addr)
59655921
struct net_buf *buf;
59665922
int err;
59675923

5968-
if (!(bt_dev.le.wl_entries < bt_dev.le.wl_size)) {
5969-
return -ENOMEM;
5970-
}
5971-
59725924
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
59735925
if (!buf) {
59745926
return -ENOBUFS;
@@ -5984,8 +5936,6 @@ int bt_le_whitelist_add(const bt_addr_le_t *addr)
59845936
return err;
59855937
}
59865938

5987-
bt_dev.le.wl_entries++;
5988-
59895939
return 0;
59905940
}
59915941

@@ -6009,7 +5959,6 @@ int bt_le_whitelist_rem(const bt_addr_le_t *addr)
60095959
return err;
60105960
}
60115961

6012-
bt_dev.le.wl_entries--;
60135962
return 0;
60145963
}
60155964

@@ -6022,7 +5971,6 @@ int bt_le_whitelist_clear(void)
60225971
return err;
60235972
}
60245973

6025-
bt_dev.le.wl_entries = 0;
60265974
return 0;
60275975
}
60285976
#endif /* defined(CONFIG_BT_WHITELIST) */

subsys/bluetooth/host/hci_core.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ struct bt_dev_le {
8484
*/
8585
u8_t rl_entries;
8686
#endif /* CONFIG_BT_SMP */
87-
88-
#if defined(CONFIG_BT_WHITELIST)
89-
/* Size of the controller whitelist. */
90-
u8_t wl_size;
91-
/* Number of entries in the resolving list. */
92-
u8_t wl_entries;
93-
#endif /* CONFIG_BT_WHITELIST */
9487
};
9588

9689
#if defined(CONFIG_BT_BREDR)

0 commit comments

Comments
 (0)