Bluetooth: Add white list lookup for incoming connection requests
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 9 Jul 2014 09:59:19 +0000 (12:59 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 9 Jul 2014 10:25:27 +0000 (12:25 +0200)
This patch adds support for looking up entries in the white list when
HCI_CONNECTABLE is not set. The logic is fairly simple: if we're
connectable check the black list, if we're not connectable check the
white list.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_event.c

index 6d1d5b3e9cd4df5740c8b1814413dc3773bc4104..c8ae9ee3cb12bfcd3f08c980283e2158db29eba0 100644 (file)
@@ -2149,10 +2149,18 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
                return;
        }
 
-       if (!hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr,
-                                   BDADDR_BREDR)) {
-               hci_reject_conn(hdev, &ev->bdaddr);
-               return;
+       if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) {
+               if (hci_bdaddr_list_lookup(&hdev->blacklist, &ev->bdaddr,
+                                          BDADDR_BREDR)) {
+                       hci_reject_conn(hdev, &ev->bdaddr);
+                       return;
+               }
+       } else {
+               if (!hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr,
+                                           BDADDR_BREDR)) {
+                       hci_reject_conn(hdev, &ev->bdaddr);
+                       return;
+               }
        }
 
        /* Connection accepted */