aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2016-09-01 13:48:28 -0400
committerMarcel Holtmann <marcel@holtmann.org>2016-09-19 14:19:34 -0400
commitaa1638dde75d00e4f549902017d0df48b77e86ff (patch)
tree3ebd54fe0d4868af0de575aa0d811298649bb75e /net/bluetooth
parentbdca1fd9a6df745857e23c6056494b7fe062b4e6 (diff)
Bluetooth: Send control open and close messages for HCI user channels
When opening and closing HCI user channel, send monitoring messages to be able to trace its behavior. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_sock.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 83e9fdb712e5..48f9471e7c85 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -493,6 +493,11 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk)
493 ver[0] = BT_SUBSYS_VERSION; 493 ver[0] = BT_SUBSYS_VERSION;
494 put_unaligned_le16(BT_SUBSYS_REVISION, ver + 1); 494 put_unaligned_le16(BT_SUBSYS_REVISION, ver + 1);
495 break; 495 break;
496 case HCI_CHANNEL_USER:
497 format = 0x0001;
498 ver[0] = BT_SUBSYS_VERSION;
499 put_unaligned_le16(BT_SUBSYS_REVISION, ver + 1);
500 break;
496 case HCI_CHANNEL_CONTROL: 501 case HCI_CHANNEL_CONTROL:
497 format = 0x0002; 502 format = 0x0002;
498 mgmt_fill_version_info(ver); 503 mgmt_fill_version_info(ver);
@@ -539,6 +544,7 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk)
539 544
540 switch (hci_pi(sk)->channel) { 545 switch (hci_pi(sk)->channel) {
541 case HCI_CHANNEL_RAW: 546 case HCI_CHANNEL_RAW:
547 case HCI_CHANNEL_USER:
542 case HCI_CHANNEL_CONTROL: 548 case HCI_CHANNEL_CONTROL:
543 break; 549 break;
544 default: 550 default:
@@ -827,6 +833,7 @@ static int hci_sock_release(struct socket *sock)
827 atomic_dec(&monitor_promisc); 833 atomic_dec(&monitor_promisc);
828 break; 834 break;
829 case HCI_CHANNEL_RAW: 835 case HCI_CHANNEL_RAW:
836 case HCI_CHANNEL_USER:
830 case HCI_CHANNEL_CONTROL: 837 case HCI_CHANNEL_CONTROL:
831 /* Send event to monitor */ 838 /* Send event to monitor */
832 skb = create_monitor_ctrl_close(sk); 839 skb = create_monitor_ctrl_close(sk);
@@ -1179,8 +1186,36 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
1179 } 1186 }
1180 1187
1181 hci_pi(sk)->channel = haddr.hci_channel; 1188 hci_pi(sk)->channel = haddr.hci_channel;
1189
1190 if (!hci_sock_gen_cookie(sk)) {
1191 /* In the case when a cookie has already been assigned,
1192 * this socket will transition from a raw socket into
1193 * an user channel socket. For a clean transition, send
1194 * the close notification first.
1195 */
1196 skb = create_monitor_ctrl_close(sk);
1197 if (skb) {
1198 hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
1199 HCI_SOCK_TRUSTED, NULL);
1200 kfree_skb(skb);
1201 }
1202 }
1203
1204 /* The user channel is restricted to CAP_NET_ADMIN
1205 * capabilities and with that implicitly trusted.
1206 */
1207 hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
1208
1182 hci_pi(sk)->hdev = hdev; 1209 hci_pi(sk)->hdev = hdev;
1183 1210
1211 /* Send event to monitor */
1212 skb = create_monitor_ctrl_open(sk);
1213 if (skb) {
1214 hci_send_to_channel(HCI_CHANNEL_MONITOR, skb,
1215 HCI_SOCK_TRUSTED, NULL);
1216 kfree_skb(skb);
1217 }
1218
1184 atomic_inc(&hdev->promisc); 1219 atomic_inc(&hdev->promisc);
1185 break; 1220 break;
1186 1221