Bluetooth: Fix redundant device (un)blocked events
Subsystems (2)
PATCH 1/1 Bluetooth: Fix redundant device (un)blocked events
From: Johan Hedberg <[email protected]>
For the Block/Unblock Device mgmt commands we should only emit the Blocked/Unblocked events on any socket except for the one which received the command. The code was previously incorrectly trying to look up a non-existent pending command and thereby ending up not skipping the command socket for the event.
We can simplify the code a lot by simply sending the event directly from the command handler functions. We have the reference to the command socket available there which makes it easy to pass to the mgmt_event function for skipping.
The only notable side-effect of this is that the old blacklisting ioctl's no-longer cause mgmt events to be emitted, however as user space versions using these ioctl's are not mgmt-aware this is acceptable.
--- include/net/bluetooth/hci_core.h | 2 -- net/bluetooth/hci_core.c | 4 ++-- net/bluetooth/mgmt.c | 50 +++++++++++++--------------------------- 3 files changed, 18 insertions(+), 38 deletions(-)
include/net/bluetooth/hci_core.h +0 -2
@@ -1325,8 +1325,6 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,void mgmt_remote_name (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 link_type,u8 addr_type,s8 rssi,u8 *name,u8 name_len);void mgmt_discovering (struct hci_dev *hdev,u8 discovering); -int mgmt_device_blocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type); -int mgmt_device_unblocked (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type);void mgmt_new_ltk (struct hci_dev *hdev,struct smp_ltk *key,bool persistent);void mgmt_new_irk (struct hci_dev *hdev,struct smp_irk *irk); void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
net/bluetooth/hci_core.c +2 -2
@@ -3275,7 +3275,7 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)list_add (&entry->list, &hdev->blacklist); -return mgmt_device_blocked (hdev, bdaddr, type); +return 0 ; }int hci_blacklist_del (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 type)
@@ -3294,7 +3294,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)list_del (&entry->list);kfree (entry); -return mgmt_device_unblocked (hdev, bdaddr, type); +return 0 ; } struct bdaddr_list *hci_white_list_lookup(struct hci_dev *hdev,
net/bluetooth/mgmt.c +16 -34
72 lines not on this page · raw message
Signature · 1 line
1.9.3
Marcel Holtmann
maintainerHi Johan,
Quoted 15 lines
For the Block/Unblock Device mgmt commands we should only emit the Blocked/Unblocked events on any socket except for the one which received the command. The code was previously incorrectly trying to look up a non-existent pending command and thereby ending up not skipping the command socket for the event.
We can simplify the code a lot by simply sending the event directly from the command handler functions. We have the reference to the command socket available there which makes it easy to pass to the
mgmt_eventfunction for skipping.The only notable side-effect of this is that the old blacklisting ioctl's no-longer cause mgmt events to be emitted, however as user space versions using these ioctl's are not mgmt-aware this is acceptable.
Quoted 6 lines
Signed-off-by Johan Hedberg <[email protected]>---
include/net/bluetooth/hci_core.h | 2 -- net/bluetooth/hci_core.c | 4 ++-- net/bluetooth/mgmt.c | 50 +++++++++++++--------------------------- 3 files changed, 18 insertions(+), 38 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel