aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-09 06:28:26 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-09 06:30:18 -0400
commit91a668b0565dddc9f556f9bce65da58264c74623 (patch)
tree4eb3d06e972db4be177d5c40697cedbba3349906
parenta55bd29d522729e0cb125474396acdc2a107d4d9 (diff)
Bluetooth: Fix setting HCI_CONNECTABLE from ioctl code
When the white list is in use the code would not update the HCI_CONNECTABLE flag if it gets changed through the ioctl code (e.g. hciconfig hci0 pscan). Since the flag is important for properly accepting incoming connections add code to fix it up if necessary and emit a New Settings mgmt event. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/bluetooth/hci_core.h1
-rw-r--r--net/bluetooth/hci_core.c17
-rw-r--r--net/bluetooth/mgmt.c5
3 files changed, 23 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index cba4837dcaa5..e69c2b08c0c6 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1281,6 +1281,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);
1281#define DISCOV_BREDR_INQUIRY_LEN 0x08 1281#define DISCOV_BREDR_INQUIRY_LEN 0x08
1282 1282
1283int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); 1283int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
1284int mgmt_new_settings(struct hci_dev *hdev);
1284void mgmt_index_added(struct hci_dev *hdev); 1285void mgmt_index_added(struct hci_dev *hdev);
1285void mgmt_index_removed(struct hci_dev *hdev); 1286void mgmt_index_removed(struct hci_dev *hdev);
1286void mgmt_set_powered_failed(struct hci_dev *hdev, int err); 1287void mgmt_set_powered_failed(struct hci_dev *hdev, int err);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 728a6ee471ea..84431b86af96 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2715,6 +2715,23 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
2715 case HCISETSCAN: 2715 case HCISETSCAN:
2716 err = hci_req_sync(hdev, hci_scan_req, dr.dev_opt, 2716 err = hci_req_sync(hdev, hci_scan_req, dr.dev_opt,
2717 HCI_INIT_TIMEOUT); 2717 HCI_INIT_TIMEOUT);
2718
2719 /* Ensure that the connectable state gets correctly
2720 * notified if the whitelist is in use.
2721 */
2722 if (!err && !list_empty(&hdev->whitelist)) {
2723 bool changed;
2724
2725 if ((dr.dev_opt & SCAN_PAGE))
2726 changed = !test_and_set_bit(HCI_CONNECTABLE,
2727 &hdev->dev_flags);
2728 else
2729 changed = test_and_set_bit(HCI_CONNECTABLE,
2730 &hdev->dev_flags);
2731
2732 if (changed)
2733 mgmt_new_settings(hdev);
2734 }
2718 break; 2735 break;
2719 2736
2720 case HCISETLINKPOL: 2737 case HCISETLINKPOL:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 98392d61b78f..91b1f92c681e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1427,6 +1427,11 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip)
1427 return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); 1427 return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip);
1428} 1428}
1429 1429
1430int mgmt_new_settings(struct hci_dev *hdev)
1431{
1432 return new_settings(hdev, NULL);
1433}
1434
1430struct cmd_lookup { 1435struct cmd_lookup {
1431 struct sock *sk; 1436 struct sock *sk;
1432 struct hci_dev *hdev; 1437 struct hci_dev *hdev;