aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h15
-rw-r--r--net/bluetooth/hci_core.c85
-rw-r--r--net/bluetooth/hci_event.c15
-rw-r--r--net/bluetooth/hci_sock.c4
-rw-r--r--net/bluetooth/l2cap_core.c7
-rw-r--r--net/bluetooth/mgmt.c6
6 files changed, 36 insertions, 96 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c98de309967e..3a1caf10cc8d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -849,16 +849,11 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
849int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); 849int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
850int hci_inquiry(void __user *arg); 850int hci_inquiry(void __user *arg);
851 851
852struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, 852struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *list,
853 bdaddr_t *bdaddr, u8 type); 853 bdaddr_t *bdaddr, u8 type);
854int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 854int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type);
855int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 855int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type);
856 856void hci_bdaddr_list_clear(struct list_head *list);
857struct bdaddr_list *hci_white_list_lookup(struct hci_dev *hdev,
858 bdaddr_t *bdaddr, u8 type);
859void hci_white_list_clear(struct hci_dev *hdev);
860int hci_white_list_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
861int hci_white_list_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
862 857
863struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, 858struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
864 bdaddr_t *addr, u8 addr_type); 859 bdaddr_t *addr, u8 addr_type);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 421faf5fa1f5..705f8df7af96 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3351,12 +3351,12 @@ int hci_add_remote_oob_ext_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
3351 return 0; 3351 return 0;
3352} 3352}
3353 3353
3354struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, 3354struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *bdaddr_list,
3355 bdaddr_t *bdaddr, u8 type) 3355 bdaddr_t *bdaddr, u8 type)
3356{ 3356{
3357 struct bdaddr_list *b; 3357 struct bdaddr_list *b;
3358 3358
3359 list_for_each_entry(b, &hdev->blacklist, list) { 3359 list_for_each_entry(b, bdaddr_list, list) {
3360 if (!bacmp(&b->bdaddr, bdaddr) && b->bdaddr_type == type) 3360 if (!bacmp(&b->bdaddr, bdaddr) && b->bdaddr_type == type)
3361 return b; 3361 return b;
3362 } 3362 }
@@ -3364,11 +3364,11 @@ struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
3364 return NULL; 3364 return NULL;
3365} 3365}
3366 3366
3367static void hci_blacklist_clear(struct hci_dev *hdev) 3367void hci_bdaddr_list_clear(struct list_head *bdaddr_list)
3368{ 3368{
3369 struct list_head *p, *n; 3369 struct list_head *p, *n;
3370 3370
3371 list_for_each_safe(p, n, &hdev->blacklist) { 3371 list_for_each_safe(p, n, bdaddr_list) {
3372 struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list); 3372 struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
3373 3373
3374 list_del(p); 3374 list_del(p);
@@ -3376,14 +3376,14 @@ static void hci_blacklist_clear(struct hci_dev *hdev)
3376 } 3376 }
3377} 3377}
3378 3378
3379int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) 3379int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type)
3380{ 3380{
3381 struct bdaddr_list *entry; 3381 struct bdaddr_list *entry;
3382 3382
3383 if (!bacmp(bdaddr, BDADDR_ANY)) 3383 if (!bacmp(bdaddr, BDADDR_ANY))
3384 return -EBADF; 3384 return -EBADF;
3385 3385
3386 if (hci_blacklist_lookup(hdev, bdaddr, type)) 3386 if (hci_bdaddr_list_lookup(list, bdaddr, type))
3387 return -EEXIST; 3387 return -EEXIST;
3388 3388
3389 entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); 3389 entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
@@ -3393,82 +3393,21 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
3393 bacpy(&entry->bdaddr, bdaddr); 3393 bacpy(&entry->bdaddr, bdaddr);
3394 entry->bdaddr_type = type; 3394 entry->bdaddr_type = type;
3395 3395
3396 list_add(&entry->list, &hdev->blacklist); 3396 list_add(&entry->list, list);
3397 3397
3398 return 0; 3398 return 0;
3399} 3399}
3400 3400
3401int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) 3401int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type)
3402{ 3402{
3403 struct bdaddr_list *entry; 3403 struct bdaddr_list *entry;
3404 3404
3405 if (!bacmp(bdaddr, BDADDR_ANY)) { 3405 if (!bacmp(bdaddr, BDADDR_ANY)) {
3406 hci_blacklist_clear(hdev); 3406 hci_bdaddr_list_clear(list);
3407 return 0; 3407 return 0;
3408 } 3408 }
3409 3409
3410 entry = hci_blacklist_lookup(hdev, bdaddr, type); 3410 entry = hci_bdaddr_list_lookup(list, bdaddr, type);
3411 if (!entry)
3412 return -ENOENT;
3413
3414 list_del(&entry->list);
3415 kfree(entry);
3416
3417 return 0;
3418}
3419
3420struct bdaddr_list *hci_white_list_lookup(struct hci_dev *hdev,
3421 bdaddr_t *bdaddr, u8 type)
3422{
3423 struct bdaddr_list *b;
3424
3425 list_for_each_entry(b, &hdev->le_white_list, list) {
3426 if (!bacmp(&b->bdaddr, bdaddr) && b->bdaddr_type == type)
3427 return b;
3428 }
3429
3430 return NULL;
3431}
3432
3433void hci_white_list_clear(struct hci_dev *hdev)
3434{
3435 struct list_head *p, *n;
3436
3437 list_for_each_safe(p, n, &hdev->le_white_list) {
3438 struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
3439
3440 list_del(p);
3441 kfree(b);
3442 }
3443}
3444
3445int hci_white_list_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
3446{
3447 struct bdaddr_list *entry;
3448
3449 if (!bacmp(bdaddr, BDADDR_ANY))
3450 return -EBADF;
3451
3452 entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
3453 if (!entry)
3454 return -ENOMEM;
3455
3456 bacpy(&entry->bdaddr, bdaddr);
3457 entry->bdaddr_type = type;
3458
3459 list_add(&entry->list, &hdev->le_white_list);
3460
3461 return 0;
3462}
3463
3464int hci_white_list_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
3465{
3466 struct bdaddr_list *entry;
3467
3468 if (!bacmp(bdaddr, BDADDR_ANY))
3469 return -EBADF;
3470
3471 entry = hci_white_list_lookup(hdev, bdaddr, type);
3472 if (!entry) 3411 if (!entry)
3473 return -ENOENT; 3412 return -ENOENT;
3474 3413
@@ -4096,13 +4035,13 @@ void hci_unregister_dev(struct hci_dev *hdev)
4096 destroy_workqueue(hdev->req_workqueue); 4035 destroy_workqueue(hdev->req_workqueue);
4097 4036
4098 hci_dev_lock(hdev); 4037 hci_dev_lock(hdev);
4099 hci_blacklist_clear(hdev); 4038 hci_bdaddr_list_clear(&hdev->blacklist);
4100 hci_uuids_clear(hdev); 4039 hci_uuids_clear(hdev);
4101 hci_link_keys_clear(hdev); 4040 hci_link_keys_clear(hdev);
4102 hci_smp_ltks_clear(hdev); 4041 hci_smp_ltks_clear(hdev);
4103 hci_smp_irks_clear(hdev); 4042 hci_smp_irks_clear(hdev);
4104 hci_remote_oob_data_clear(hdev); 4043 hci_remote_oob_data_clear(hdev);
4105 hci_white_list_clear(hdev); 4044 hci_bdaddr_list_clear(&hdev->le_white_list);
4106 hci_conn_params_clear_all(hdev); 4045 hci_conn_params_clear_all(hdev);
4107 hci_dev_unlock(hdev); 4046 hci_dev_unlock(hdev);
4108 4047
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f6997901bdd7..381c631423f1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1222,7 +1222,7 @@ static void hci_cc_le_clear_white_list(struct hci_dev *hdev,
1222 if (status) 1222 if (status)
1223 return; 1223 return;
1224 1224
1225 hci_white_list_clear(hdev); 1225 hci_bdaddr_list_clear(&hdev->le_white_list);
1226} 1226}
1227 1227
1228static void hci_cc_le_add_to_white_list(struct hci_dev *hdev, 1228static void hci_cc_le_add_to_white_list(struct hci_dev *hdev,
@@ -1240,7 +1240,8 @@ static void hci_cc_le_add_to_white_list(struct hci_dev *hdev,
1240 if (!sent) 1240 if (!sent)
1241 return; 1241 return;
1242 1242
1243 hci_white_list_add(hdev, &sent->bdaddr, sent->bdaddr_type); 1243 hci_bdaddr_list_add(&hdev->le_white_list, &sent->bdaddr,
1244 sent->bdaddr_type);
1244} 1245}
1245 1246
1246static void hci_cc_le_del_from_white_list(struct hci_dev *hdev, 1247static void hci_cc_le_del_from_white_list(struct hci_dev *hdev,
@@ -1258,7 +1259,8 @@ static void hci_cc_le_del_from_white_list(struct hci_dev *hdev,
1258 if (!sent) 1259 if (!sent)
1259 return; 1260 return;
1260 1261
1261 hci_white_list_del(hdev, &sent->bdaddr, sent->bdaddr_type); 1262 hci_bdaddr_list_del(&hdev->le_white_list, &sent->bdaddr,
1263 sent->bdaddr_type);
1262} 1264}
1263 1265
1264static void hci_cc_le_read_supported_states(struct hci_dev *hdev, 1266static void hci_cc_le_read_supported_states(struct hci_dev *hdev,
@@ -2132,7 +2134,8 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
2132 &flags); 2134 &flags);
2133 2135
2134 if ((mask & HCI_LM_ACCEPT) && 2136 if ((mask & HCI_LM_ACCEPT) &&
2135 !hci_blacklist_lookup(hdev, &ev->bdaddr, BDADDR_BREDR)) { 2137 !hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr,
2138 BDADDR_BREDR)) {
2136 /* Connection accepted */ 2139 /* Connection accepted */
2137 struct inquiry_entry *ie; 2140 struct inquiry_entry *ie;
2138 struct hci_conn *conn; 2141 struct hci_conn *conn;
@@ -4184,7 +4187,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
4184 addr_type = BDADDR_LE_RANDOM; 4187 addr_type = BDADDR_LE_RANDOM;
4185 4188
4186 /* Drop the connection if he device is blocked */ 4189 /* Drop the connection if he device is blocked */
4187 if (hci_blacklist_lookup(hdev, &conn->dst, addr_type)) { 4190 if (hci_bdaddr_list_lookup(&hdev->blacklist, &conn->dst, addr_type)) {
4188 hci_conn_drop(conn); 4191 hci_conn_drop(conn);
4189 goto unlock; 4192 goto unlock;
4190 } 4193 }
@@ -4253,7 +4256,7 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
4253 return; 4256 return;
4254 4257
4255 /* Ignore if the device is blocked */ 4258 /* Ignore if the device is blocked */
4256 if (hci_blacklist_lookup(hdev, addr, addr_type)) 4259 if (hci_bdaddr_list_lookup(&hdev->blacklist, addr, addr_type))
4257 return; 4260 return;
4258 4261
4259 /* If we're connectable, always connect any ADV_DIRECT_IND event */ 4262 /* If we're connectable, always connect any ADV_DIRECT_IND event */
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 802665751cc4..c64728d571ae 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -481,7 +481,7 @@ static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg)
481 481
482 hci_dev_lock(hdev); 482 hci_dev_lock(hdev);
483 483
484 err = hci_blacklist_add(hdev, &bdaddr, BDADDR_BREDR); 484 err = hci_bdaddr_list_add(&hdev->blacklist, &bdaddr, BDADDR_BREDR);
485 485
486 hci_dev_unlock(hdev); 486 hci_dev_unlock(hdev);
487 487
@@ -498,7 +498,7 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg)
498 498
499 hci_dev_lock(hdev); 499 hci_dev_lock(hdev);
500 500
501 err = hci_blacklist_del(hdev, &bdaddr, BDADDR_BREDR); 501 err = hci_bdaddr_list_del(&hdev->blacklist, &bdaddr, BDADDR_BREDR);
502 502
503 hci_dev_unlock(hdev); 503 hci_dev_unlock(hdev);
504 504
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index bf379a379fa0..d006e6c0e3b4 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1460,6 +1460,7 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
1460static void l2cap_le_conn_ready(struct l2cap_conn *conn) 1460static void l2cap_le_conn_ready(struct l2cap_conn *conn)
1461{ 1461{
1462 struct hci_conn *hcon = conn->hcon; 1462 struct hci_conn *hcon = conn->hcon;
1463 struct hci_dev *hdev = hcon->hdev;
1463 struct l2cap_chan *chan, *pchan; 1464 struct l2cap_chan *chan, *pchan;
1464 u8 dst_type; 1465 u8 dst_type;
1465 1466
@@ -1478,7 +1479,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
1478 dst_type = bdaddr_type(hcon, hcon->dst_type); 1479 dst_type = bdaddr_type(hcon, hcon->dst_type);
1479 1480
1480 /* If device is blocked, do not create a channel for it */ 1481 /* If device is blocked, do not create a channel for it */
1481 if (hci_blacklist_lookup(hcon->hdev, &hcon->dst, dst_type)) 1482 if (hci_bdaddr_list_lookup(&hdev->blacklist, &hcon->dst, dst_type))
1482 return; 1483 return;
1483 1484
1484 /* For LE slave connections, make sure the connection interval 1485 /* For LE slave connections, make sure the connection interval
@@ -6918,8 +6919,8 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
6918 * at least ensure that we ignore incoming data from them. 6919 * at least ensure that we ignore incoming data from them.
6919 */ 6920 */
6920 if (hcon->type == LE_LINK && 6921 if (hcon->type == LE_LINK &&
6921 hci_blacklist_lookup(hcon->hdev, &hcon->dst, 6922 hci_bdaddr_list_lookup(&hcon->hdev->blacklist, &hcon->dst,
6922 bdaddr_type(hcon, hcon->dst_type))) { 6923 bdaddr_type(hcon, hcon->dst_type))) {
6923 kfree_skb(skb); 6924 kfree_skb(skb);
6924 return; 6925 return;
6925 } 6926 }
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 216aa93514b6..592e73eea76d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3956,7 +3956,8 @@ static int block_device(struct sock *sk, struct hci_dev *hdev, void *data,
3956 3956
3957 hci_dev_lock(hdev); 3957 hci_dev_lock(hdev);
3958 3958
3959 err = hci_blacklist_add(hdev, &cp->addr.bdaddr, cp->addr.type); 3959 err = hci_bdaddr_list_add(&hdev->blacklist, &cp->addr.bdaddr,
3960 cp->addr.type);
3960 if (err < 0) { 3961 if (err < 0) {
3961 status = MGMT_STATUS_FAILED; 3962 status = MGMT_STATUS_FAILED;
3962 goto done; 3963 goto done;
@@ -3991,7 +3992,8 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data,
3991 3992
3992 hci_dev_lock(hdev); 3993 hci_dev_lock(hdev);
3993 3994
3994 err = hci_blacklist_del(hdev, &cp->addr.bdaddr, cp->addr.type); 3995 err = hci_bdaddr_list_del(&hdev->blacklist, &cp->addr.bdaddr,
3996 cp->addr.type);
3995 if (err < 0) { 3997 if (err < 0) {
3996 status = MGMT_STATUS_INVALID_PARAMS; 3998 status = MGMT_STATUS_INVALID_PARAMS;
3997 goto done; 3999 goto done;