diff options
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 11 | ||||
-rw-r--r-- | net/bluetooth/bnep/core.c | 5 | ||||
-rw-r--r-- | net/bluetooth/bnep/sock.c | 5 | ||||
-rw-r--r-- | net/bluetooth/cmtp/sock.c | 5 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 39 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 6 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 16 | ||||
-rw-r--r-- | net/bluetooth/hidp/core.c | 9 | ||||
-rw-r--r-- | net/bluetooth/hidp/sock.c | 5 | ||||
-rw-r--r-- | net/bluetooth/l2cap.c | 137 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 7 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 5 |
13 files changed, 188 insertions, 68 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 8cfb5a849841..087cc51f5927 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | /* Bluetooth sockets */ | 46 | /* Bluetooth sockets */ |
47 | #define BT_MAX_PROTO 8 | 47 | #define BT_MAX_PROTO 8 |
48 | static struct net_proto_family *bt_proto[BT_MAX_PROTO]; | 48 | static const struct net_proto_family *bt_proto[BT_MAX_PROTO]; |
49 | static DEFINE_RWLOCK(bt_proto_lock); | 49 | static DEFINE_RWLOCK(bt_proto_lock); |
50 | 50 | ||
51 | static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; | 51 | static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; |
@@ -86,7 +86,7 @@ static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) | |||
86 | bt_key_strings[proto], &bt_lock_key[proto]); | 86 | bt_key_strings[proto], &bt_lock_key[proto]); |
87 | } | 87 | } |
88 | 88 | ||
89 | int bt_sock_register(int proto, struct net_proto_family *ops) | 89 | int bt_sock_register(int proto, const struct net_proto_family *ops) |
90 | { | 90 | { |
91 | int err = 0; | 91 | int err = 0; |
92 | 92 | ||
@@ -126,7 +126,8 @@ int bt_sock_unregister(int proto) | |||
126 | } | 126 | } |
127 | EXPORT_SYMBOL(bt_sock_unregister); | 127 | EXPORT_SYMBOL(bt_sock_unregister); |
128 | 128 | ||
129 | static int bt_sock_create(struct net *net, struct socket *sock, int proto) | 129 | static int bt_sock_create(struct net *net, struct socket *sock, int proto, |
130 | int kern) | ||
130 | { | 131 | { |
131 | int err; | 132 | int err; |
132 | 133 | ||
@@ -144,7 +145,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto) | |||
144 | read_lock(&bt_proto_lock); | 145 | read_lock(&bt_proto_lock); |
145 | 146 | ||
146 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { | 147 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { |
147 | err = bt_proto[proto]->create(net, sock, proto); | 148 | err = bt_proto[proto]->create(net, sock, proto, kern); |
148 | bt_sock_reclassify_lock(sock, proto); | 149 | bt_sock_reclassify_lock(sock, proto); |
149 | module_put(bt_proto[proto]->owner); | 150 | module_put(bt_proto[proto]->owner); |
150 | } | 151 | } |
@@ -257,7 +258,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
257 | skb_reset_transport_header(skb); | 258 | skb_reset_transport_header(skb); |
258 | err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); | 259 | err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); |
259 | if (err == 0) | 260 | if (err == 0) |
260 | sock_recv_timestamp(msg, sk, skb); | 261 | sock_recv_ts_and_drops(msg, sk, skb); |
261 | 262 | ||
262 | skb_free_datagram(sk, skb); | 263 | skb_free_datagram(sk, skb); |
263 | 264 | ||
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 9ac0497decb8..ef09c7b3a858 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -230,7 +230,6 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len) | |||
230 | 230 | ||
231 | switch (cmd) { | 231 | switch (cmd) { |
232 | case BNEP_CMD_NOT_UNDERSTOOD: | 232 | case BNEP_CMD_NOT_UNDERSTOOD: |
233 | case BNEP_SETUP_CONN_REQ: | ||
234 | case BNEP_SETUP_CONN_RSP: | 233 | case BNEP_SETUP_CONN_RSP: |
235 | case BNEP_FILTER_NET_TYPE_RSP: | 234 | case BNEP_FILTER_NET_TYPE_RSP: |
236 | case BNEP_FILTER_MULTI_ADDR_RSP: | 235 | case BNEP_FILTER_MULTI_ADDR_RSP: |
@@ -245,6 +244,10 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len) | |||
245 | err = bnep_ctrl_set_mcfilter(s, data, len); | 244 | err = bnep_ctrl_set_mcfilter(s, data, len); |
246 | break; | 245 | break; |
247 | 246 | ||
247 | case BNEP_SETUP_CONN_REQ: | ||
248 | err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, BNEP_CONN_NOT_ALLOWED); | ||
249 | break; | ||
250 | |||
248 | default: { | 251 | default: { |
249 | u8 pkt[3]; | 252 | u8 pkt[3]; |
250 | pkt[0] = BNEP_CONTROL; | 253 | pkt[0] = BNEP_CONTROL; |
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index e857628b0b27..2ff6ac7b2ed4 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c | |||
@@ -195,7 +195,8 @@ static struct proto bnep_proto = { | |||
195 | .obj_size = sizeof(struct bt_sock) | 195 | .obj_size = sizeof(struct bt_sock) |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static int bnep_sock_create(struct net *net, struct socket *sock, int protocol) | 198 | static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, |
199 | int kern) | ||
199 | { | 200 | { |
200 | struct sock *sk; | 201 | struct sock *sk; |
201 | 202 | ||
@@ -222,7 +223,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol) | |||
222 | return 0; | 223 | return 0; |
223 | } | 224 | } |
224 | 225 | ||
225 | static struct net_proto_family bnep_sock_family_ops = { | 226 | static const struct net_proto_family bnep_sock_family_ops = { |
226 | .family = PF_BLUETOOTH, | 227 | .family = PF_BLUETOOTH, |
227 | .owner = THIS_MODULE, | 228 | .owner = THIS_MODULE, |
228 | .create = bnep_sock_create | 229 | .create = bnep_sock_create |
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 16b0fad74f6e..978cc3a718ad 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c | |||
@@ -190,7 +190,8 @@ static struct proto cmtp_proto = { | |||
190 | .obj_size = sizeof(struct bt_sock) | 190 | .obj_size = sizeof(struct bt_sock) |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol) | 193 | static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol, |
194 | int kern) | ||
194 | { | 195 | { |
195 | struct sock *sk; | 196 | struct sock *sk; |
196 | 197 | ||
@@ -217,7 +218,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol) | |||
217 | return 0; | 218 | return 0; |
218 | } | 219 | } |
219 | 220 | ||
220 | static struct net_proto_family cmtp_sock_family_ops = { | 221 | static const struct net_proto_family cmtp_sock_family_ops = { |
221 | .family = PF_BLUETOOTH, | 222 | .family = PF_BLUETOOTH, |
222 | .owner = THIS_MODULE, | 223 | .owner = THIS_MODULE, |
223 | .create = cmtp_sock_create | 224 | .create = cmtp_sock_create |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e1da8f68759c..94ba34982021 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -193,8 +193,9 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) | |||
193 | while ((skb = skb_dequeue(&hdev->driver_init))) { | 193 | while ((skb = skb_dequeue(&hdev->driver_init))) { |
194 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; | 194 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; |
195 | skb->dev = (void *) hdev; | 195 | skb->dev = (void *) hdev; |
196 | |||
196 | skb_queue_tail(&hdev->cmd_q, skb); | 197 | skb_queue_tail(&hdev->cmd_q, skb); |
197 | hci_sched_cmd(hdev); | 198 | tasklet_schedule(&hdev->cmd_task); |
198 | } | 199 | } |
199 | skb_queue_purge(&hdev->driver_init); | 200 | skb_queue_purge(&hdev->driver_init); |
200 | 201 | ||
@@ -987,6 +988,30 @@ int hci_resume_dev(struct hci_dev *hdev) | |||
987 | } | 988 | } |
988 | EXPORT_SYMBOL(hci_resume_dev); | 989 | EXPORT_SYMBOL(hci_resume_dev); |
989 | 990 | ||
991 | /* Receive frame from HCI drivers */ | ||
992 | int hci_recv_frame(struct sk_buff *skb) | ||
993 | { | ||
994 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; | ||
995 | if (!hdev || (!test_bit(HCI_UP, &hdev->flags) | ||
996 | && !test_bit(HCI_INIT, &hdev->flags))) { | ||
997 | kfree_skb(skb); | ||
998 | return -ENXIO; | ||
999 | } | ||
1000 | |||
1001 | /* Incomming skb */ | ||
1002 | bt_cb(skb)->incoming = 1; | ||
1003 | |||
1004 | /* Time stamp */ | ||
1005 | __net_timestamp(skb); | ||
1006 | |||
1007 | /* Queue frame for rx task */ | ||
1008 | skb_queue_tail(&hdev->rx_q, skb); | ||
1009 | tasklet_schedule(&hdev->rx_task); | ||
1010 | |||
1011 | return 0; | ||
1012 | } | ||
1013 | EXPORT_SYMBOL(hci_recv_frame); | ||
1014 | |||
990 | /* Receive packet type fragment */ | 1015 | /* Receive packet type fragment */ |
991 | #define __reassembly(hdev, type) ((hdev)->reassembly[(type) - 2]) | 1016 | #define __reassembly(hdev, type) ((hdev)->reassembly[(type) - 2]) |
992 | 1017 | ||
@@ -1193,8 +1218,9 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param) | |||
1193 | 1218 | ||
1194 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; | 1219 | bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; |
1195 | skb->dev = (void *) hdev; | 1220 | skb->dev = (void *) hdev; |
1221 | |||
1196 | skb_queue_tail(&hdev->cmd_q, skb); | 1222 | skb_queue_tail(&hdev->cmd_q, skb); |
1197 | hci_sched_cmd(hdev); | 1223 | tasklet_schedule(&hdev->cmd_task); |
1198 | 1224 | ||
1199 | return 0; | 1225 | return 0; |
1200 | } | 1226 | } |
@@ -1271,7 +1297,8 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) | |||
1271 | spin_unlock_bh(&conn->data_q.lock); | 1297 | spin_unlock_bh(&conn->data_q.lock); |
1272 | } | 1298 | } |
1273 | 1299 | ||
1274 | hci_sched_tx(hdev); | 1300 | tasklet_schedule(&hdev->tx_task); |
1301 | |||
1275 | return 0; | 1302 | return 0; |
1276 | } | 1303 | } |
1277 | EXPORT_SYMBOL(hci_send_acl); | 1304 | EXPORT_SYMBOL(hci_send_acl); |
@@ -1298,8 +1325,10 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb) | |||
1298 | 1325 | ||
1299 | skb->dev = (void *) hdev; | 1326 | skb->dev = (void *) hdev; |
1300 | bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; | 1327 | bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; |
1328 | |||
1301 | skb_queue_tail(&conn->data_q, skb); | 1329 | skb_queue_tail(&conn->data_q, skb); |
1302 | hci_sched_tx(hdev); | 1330 | tasklet_schedule(&hdev->tx_task); |
1331 | |||
1303 | return 0; | 1332 | return 0; |
1304 | } | 1333 | } |
1305 | EXPORT_SYMBOL(hci_send_sco); | 1334 | EXPORT_SYMBOL(hci_send_sco); |
@@ -1612,7 +1641,7 @@ static void hci_cmd_task(unsigned long arg) | |||
1612 | hdev->cmd_last_tx = jiffies; | 1641 | hdev->cmd_last_tx = jiffies; |
1613 | } else { | 1642 | } else { |
1614 | skb_queue_head(&hdev->cmd_q, skb); | 1643 | skb_queue_head(&hdev->cmd_q, skb); |
1615 | hci_sched_cmd(hdev); | 1644 | tasklet_schedule(&hdev->cmd_task); |
1616 | } | 1645 | } |
1617 | } | 1646 | } |
1618 | } | 1647 | } |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e99fe385fba2..28517bad796c 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1320,7 +1320,7 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk | |||
1320 | if (ev->ncmd) { | 1320 | if (ev->ncmd) { |
1321 | atomic_set(&hdev->cmd_cnt, 1); | 1321 | atomic_set(&hdev->cmd_cnt, 1); |
1322 | if (!skb_queue_empty(&hdev->cmd_q)) | 1322 | if (!skb_queue_empty(&hdev->cmd_q)) |
1323 | hci_sched_cmd(hdev); | 1323 | tasklet_schedule(&hdev->cmd_task); |
1324 | } | 1324 | } |
1325 | } | 1325 | } |
1326 | 1326 | ||
@@ -1386,7 +1386,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
1386 | if (ev->ncmd) { | 1386 | if (ev->ncmd) { |
1387 | atomic_set(&hdev->cmd_cnt, 1); | 1387 | atomic_set(&hdev->cmd_cnt, 1); |
1388 | if (!skb_queue_empty(&hdev->cmd_q)) | 1388 | if (!skb_queue_empty(&hdev->cmd_q)) |
1389 | hci_sched_cmd(hdev); | 1389 | tasklet_schedule(&hdev->cmd_task); |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | 1392 | ||
@@ -1454,7 +1454,7 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s | |||
1454 | } | 1454 | } |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | hci_sched_tx(hdev); | 1457 | tasklet_schedule(&hdev->tx_task); |
1458 | 1458 | ||
1459 | tasklet_enable(&hdev->tx_task); | 1459 | tasklet_enable(&hdev->tx_task); |
1460 | } | 1460 | } |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 75302a986067..688cfebfbee0 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -414,6 +414,11 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
414 | goto done; | 414 | goto done; |
415 | } | 415 | } |
416 | 416 | ||
417 | if (!test_bit(HCI_UP, &hdev->flags)) { | ||
418 | err = -ENETDOWN; | ||
419 | goto done; | ||
420 | } | ||
421 | |||
417 | if (!(skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err))) | 422 | if (!(skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err))) |
418 | goto done; | 423 | goto done; |
419 | 424 | ||
@@ -440,10 +445,10 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
440 | 445 | ||
441 | if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { | 446 | if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { |
442 | skb_queue_tail(&hdev->raw_q, skb); | 447 | skb_queue_tail(&hdev->raw_q, skb); |
443 | hci_sched_tx(hdev); | 448 | tasklet_schedule(&hdev->tx_task); |
444 | } else { | 449 | } else { |
445 | skb_queue_tail(&hdev->cmd_q, skb); | 450 | skb_queue_tail(&hdev->cmd_q, skb); |
446 | hci_sched_cmd(hdev); | 451 | tasklet_schedule(&hdev->cmd_task); |
447 | } | 452 | } |
448 | } else { | 453 | } else { |
449 | if (!capable(CAP_NET_RAW)) { | 454 | if (!capable(CAP_NET_RAW)) { |
@@ -452,7 +457,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
452 | } | 457 | } |
453 | 458 | ||
454 | skb_queue_tail(&hdev->raw_q, skb); | 459 | skb_queue_tail(&hdev->raw_q, skb); |
455 | hci_sched_tx(hdev); | 460 | tasklet_schedule(&hdev->tx_task); |
456 | } | 461 | } |
457 | 462 | ||
458 | err = len; | 463 | err = len; |
@@ -621,7 +626,8 @@ static struct proto hci_sk_proto = { | |||
621 | .obj_size = sizeof(struct hci_pinfo) | 626 | .obj_size = sizeof(struct hci_pinfo) |
622 | }; | 627 | }; |
623 | 628 | ||
624 | static int hci_sock_create(struct net *net, struct socket *sock, int protocol) | 629 | static int hci_sock_create(struct net *net, struct socket *sock, int protocol, |
630 | int kern) | ||
625 | { | 631 | { |
626 | struct sock *sk; | 632 | struct sock *sk; |
627 | 633 | ||
@@ -687,7 +693,7 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, | |||
687 | return NOTIFY_DONE; | 693 | return NOTIFY_DONE; |
688 | } | 694 | } |
689 | 695 | ||
690 | static struct net_proto_family hci_sock_family_ops = { | 696 | static const struct net_proto_family hci_sock_family_ops = { |
691 | .family = PF_BLUETOOTH, | 697 | .family = PF_BLUETOOTH, |
692 | .owner = THIS_MODULE, | 698 | .owner = THIS_MODULE, |
693 | .create = hci_sock_create, | 699 | .create = hci_sock_create, |
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 49d8495d69be..569750010fd3 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -280,6 +280,13 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep | |||
280 | return hidp_queue_report(session, buf, rsize); | 280 | return hidp_queue_report(session, buf, rsize); |
281 | } | 281 | } |
282 | 282 | ||
283 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count) | ||
284 | { | ||
285 | if (hidp_queue_report(hid->driver_data, data, count)) | ||
286 | return -ENOMEM; | ||
287 | return count; | ||
288 | } | ||
289 | |||
283 | static void hidp_idle_timeout(unsigned long arg) | 290 | static void hidp_idle_timeout(unsigned long arg) |
284 | { | 291 | { |
285 | struct hidp_session *session = (struct hidp_session *) arg; | 292 | struct hidp_session *session = (struct hidp_session *) arg; |
@@ -785,6 +792,8 @@ static int hidp_setup_hid(struct hidp_session *session, | |||
785 | hid->dev.parent = hidp_get_device(session); | 792 | hid->dev.parent = hidp_get_device(session); |
786 | hid->ll_driver = &hidp_hid_driver; | 793 | hid->ll_driver = &hidp_hid_driver; |
787 | 794 | ||
795 | hid->hid_output_raw_report = hidp_output_raw_report; | ||
796 | |||
788 | err = hid_add_device(hid); | 797 | err = hid_add_device(hid); |
789 | if (err < 0) | 798 | if (err < 0) |
790 | goto failed; | 799 | goto failed; |
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 37c9d7d2e688..9cfef68b9fec 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c | |||
@@ -241,7 +241,8 @@ static struct proto hidp_proto = { | |||
241 | .obj_size = sizeof(struct bt_sock) | 241 | .obj_size = sizeof(struct bt_sock) |
242 | }; | 242 | }; |
243 | 243 | ||
244 | static int hidp_sock_create(struct net *net, struct socket *sock, int protocol) | 244 | static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, |
245 | int kern) | ||
245 | { | 246 | { |
246 | struct sock *sk; | 247 | struct sock *sk; |
247 | 248 | ||
@@ -268,7 +269,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol) | |||
268 | return 0; | 269 | return 0; |
269 | } | 270 | } |
270 | 271 | ||
271 | static struct net_proto_family hidp_sock_family_ops = { | 272 | static const struct net_proto_family hidp_sock_family_ops = { |
272 | .family = PF_BLUETOOTH, | 273 | .family = PF_BLUETOOTH, |
273 | .owner = THIS_MODULE, | 274 | .owner = THIS_MODULE, |
274 | .create = hidp_sock_create | 275 | .create = hidp_sock_create |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 947f8bbb4bb3..5129b88c8e5b 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #define VERSION "2.14" | 54 | #define VERSION "2.14" |
55 | 55 | ||
56 | static int enable_ertm = 0; | 56 | static int enable_ertm = 0; |
57 | static int max_transmit = L2CAP_DEFAULT_MAX_TX; | ||
57 | 58 | ||
58 | static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN; | 59 | static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN; |
59 | static u8 l2cap_fixed_chan[8] = { 0x02, }; | 60 | static u8 l2cap_fixed_chan[8] = { 0x02, }; |
@@ -373,6 +374,8 @@ static inline int l2cap_send_rr_or_rnr(struct l2cap_pinfo *pi, u16 control) | |||
373 | else | 374 | else |
374 | control |= L2CAP_SUPER_RCV_READY; | 375 | control |= L2CAP_SUPER_RCV_READY; |
375 | 376 | ||
377 | control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; | ||
378 | |||
376 | return l2cap_send_sframe(pi, control); | 379 | return l2cap_send_sframe(pi, control); |
377 | } | 380 | } |
378 | 381 | ||
@@ -819,7 +822,8 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p | |||
819 | return sk; | 822 | return sk; |
820 | } | 823 | } |
821 | 824 | ||
822 | static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol) | 825 | static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, |
826 | int kern) | ||
823 | { | 827 | { |
824 | struct sock *sk; | 828 | struct sock *sk; |
825 | 829 | ||
@@ -831,7 +835,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol) | |||
831 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) | 835 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) |
832 | return -ESOCKTNOSUPPORT; | 836 | return -ESOCKTNOSUPPORT; |
833 | 837 | ||
834 | if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW)) | 838 | if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) |
835 | return -EPERM; | 839 | return -EPERM; |
836 | 840 | ||
837 | sock->ops = &l2cap_sock_ops; | 841 | sock->ops = &l2cap_sock_ops; |
@@ -1332,7 +1336,7 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq) | |||
1332 | tx_skb = skb_clone(skb, GFP_ATOMIC); | 1336 | tx_skb = skb_clone(skb, GFP_ATOMIC); |
1333 | bt_cb(skb)->retries++; | 1337 | bt_cb(skb)->retries++; |
1334 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); | 1338 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); |
1335 | control |= (pi->req_seq << L2CAP_CTRL_REQSEQ_SHIFT) | 1339 | control |= (pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) |
1336 | | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); | 1340 | | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); |
1337 | put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); | 1341 | put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); |
1338 | 1342 | ||
@@ -1361,8 +1365,8 @@ static int l2cap_ertm_send(struct sock *sk) | |||
1361 | if (pi->conn_state & L2CAP_CONN_WAIT_F) | 1365 | if (pi->conn_state & L2CAP_CONN_WAIT_F) |
1362 | return 0; | 1366 | return 0; |
1363 | 1367 | ||
1364 | while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(sk)) | 1368 | while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(sk)) && |
1365 | && !(pi->conn_state & L2CAP_CONN_REMOTE_BUSY)) { | 1369 | !(pi->conn_state & L2CAP_CONN_REMOTE_BUSY)) { |
1366 | tx_skb = skb_clone(skb, GFP_ATOMIC); | 1370 | tx_skb = skb_clone(skb, GFP_ATOMIC); |
1367 | 1371 | ||
1368 | if (pi->remote_max_tx && | 1372 | if (pi->remote_max_tx && |
@@ -1374,7 +1378,7 @@ static int l2cap_ertm_send(struct sock *sk) | |||
1374 | bt_cb(skb)->retries++; | 1378 | bt_cb(skb)->retries++; |
1375 | 1379 | ||
1376 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); | 1380 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); |
1377 | control |= (pi->req_seq << L2CAP_CTRL_REQSEQ_SHIFT) | 1381 | control |= (pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) |
1378 | | (pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); | 1382 | | (pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); |
1379 | put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); | 1383 | put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); |
1380 | 1384 | ||
@@ -1603,8 +1607,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
1603 | return -EOPNOTSUPP; | 1607 | return -EOPNOTSUPP; |
1604 | 1608 | ||
1605 | /* Check outgoing MTU */ | 1609 | /* Check outgoing MTU */ |
1606 | if (sk->sk_type == SOCK_SEQPACKET && pi->mode == L2CAP_MODE_BASIC | 1610 | if (sk->sk_type == SOCK_SEQPACKET && pi->mode == L2CAP_MODE_BASIC && |
1607 | && len > pi->omtu) | 1611 | len > pi->omtu) |
1608 | return -EINVAL; | 1612 | return -EINVAL; |
1609 | 1613 | ||
1610 | lock_sock(sk); | 1614 | lock_sock(sk); |
@@ -2172,6 +2176,21 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) | |||
2172 | *ptr += L2CAP_CONF_OPT_SIZE + len; | 2176 | *ptr += L2CAP_CONF_OPT_SIZE + len; |
2173 | } | 2177 | } |
2174 | 2178 | ||
2179 | static inline void l2cap_ertm_init(struct sock *sk) | ||
2180 | { | ||
2181 | l2cap_pi(sk)->expected_ack_seq = 0; | ||
2182 | l2cap_pi(sk)->unacked_frames = 0; | ||
2183 | l2cap_pi(sk)->buffer_seq = 0; | ||
2184 | l2cap_pi(sk)->num_to_ack = 0; | ||
2185 | |||
2186 | setup_timer(&l2cap_pi(sk)->retrans_timer, | ||
2187 | l2cap_retrans_timeout, (unsigned long) sk); | ||
2188 | setup_timer(&l2cap_pi(sk)->monitor_timer, | ||
2189 | l2cap_monitor_timeout, (unsigned long) sk); | ||
2190 | |||
2191 | __skb_queue_head_init(SREJ_QUEUE(sk)); | ||
2192 | } | ||
2193 | |||
2175 | static int l2cap_mode_supported(__u8 mode, __u32 feat_mask) | 2194 | static int l2cap_mode_supported(__u8 mode, __u32 feat_mask) |
2176 | { | 2195 | { |
2177 | u32 local_feat_mask = l2cap_feat_mask; | 2196 | u32 local_feat_mask = l2cap_feat_mask; |
@@ -2235,7 +2254,7 @@ done: | |||
2235 | case L2CAP_MODE_ERTM: | 2254 | case L2CAP_MODE_ERTM: |
2236 | rfc.mode = L2CAP_MODE_ERTM; | 2255 | rfc.mode = L2CAP_MODE_ERTM; |
2237 | rfc.txwin_size = L2CAP_DEFAULT_TX_WINDOW; | 2256 | rfc.txwin_size = L2CAP_DEFAULT_TX_WINDOW; |
2238 | rfc.max_transmit = L2CAP_DEFAULT_MAX_TX; | 2257 | rfc.max_transmit = max_transmit; |
2239 | rfc.retrans_timeout = 0; | 2258 | rfc.retrans_timeout = 0; |
2240 | rfc.monitor_timeout = 0; | 2259 | rfc.monitor_timeout = 0; |
2241 | rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); | 2260 | rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); |
@@ -2755,22 +2774,18 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2755 | goto unlock; | 2774 | goto unlock; |
2756 | 2775 | ||
2757 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { | 2776 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { |
2758 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) | 2777 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) || |
2759 | || l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) | 2778 | l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) |
2760 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; | 2779 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; |
2761 | 2780 | ||
2762 | sk->sk_state = BT_CONNECTED; | 2781 | sk->sk_state = BT_CONNECTED; |
2763 | l2cap_pi(sk)->next_tx_seq = 0; | ||
2764 | l2cap_pi(sk)->expected_ack_seq = 0; | ||
2765 | l2cap_pi(sk)->unacked_frames = 0; | ||
2766 | |||
2767 | setup_timer(&l2cap_pi(sk)->retrans_timer, | ||
2768 | l2cap_retrans_timeout, (unsigned long) sk); | ||
2769 | setup_timer(&l2cap_pi(sk)->monitor_timer, | ||
2770 | l2cap_monitor_timeout, (unsigned long) sk); | ||
2771 | 2782 | ||
2783 | l2cap_pi(sk)->next_tx_seq = 0; | ||
2784 | l2cap_pi(sk)->expected_tx_seq = 0; | ||
2772 | __skb_queue_head_init(TX_QUEUE(sk)); | 2785 | __skb_queue_head_init(TX_QUEUE(sk)); |
2773 | __skb_queue_head_init(SREJ_QUEUE(sk)); | 2786 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) |
2787 | l2cap_ertm_init(sk); | ||
2788 | |||
2774 | l2cap_chan_ready(sk); | 2789 | l2cap_chan_ready(sk); |
2775 | goto unlock; | 2790 | goto unlock; |
2776 | } | 2791 | } |
@@ -2844,16 +2859,17 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2844 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; | 2859 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; |
2845 | 2860 | ||
2846 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { | 2861 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { |
2847 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) | 2862 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) || |
2848 | || l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) | 2863 | l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) |
2849 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; | 2864 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; |
2850 | 2865 | ||
2851 | sk->sk_state = BT_CONNECTED; | 2866 | sk->sk_state = BT_CONNECTED; |
2867 | l2cap_pi(sk)->next_tx_seq = 0; | ||
2852 | l2cap_pi(sk)->expected_tx_seq = 0; | 2868 | l2cap_pi(sk)->expected_tx_seq = 0; |
2853 | l2cap_pi(sk)->buffer_seq = 0; | ||
2854 | l2cap_pi(sk)->num_to_ack = 0; | ||
2855 | __skb_queue_head_init(TX_QUEUE(sk)); | 2869 | __skb_queue_head_init(TX_QUEUE(sk)); |
2856 | __skb_queue_head_init(SREJ_QUEUE(sk)); | 2870 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) |
2871 | l2cap_ertm_init(sk); | ||
2872 | |||
2857 | l2cap_chan_ready(sk); | 2873 | l2cap_chan_ready(sk); |
2858 | } | 2874 | } |
2859 | 2875 | ||
@@ -2885,9 +2901,12 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd | |||
2885 | sk->sk_shutdown = SHUTDOWN_MASK; | 2901 | sk->sk_shutdown = SHUTDOWN_MASK; |
2886 | 2902 | ||
2887 | skb_queue_purge(TX_QUEUE(sk)); | 2903 | skb_queue_purge(TX_QUEUE(sk)); |
2888 | skb_queue_purge(SREJ_QUEUE(sk)); | 2904 | |
2889 | del_timer(&l2cap_pi(sk)->retrans_timer); | 2905 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { |
2890 | del_timer(&l2cap_pi(sk)->monitor_timer); | 2906 | skb_queue_purge(SREJ_QUEUE(sk)); |
2907 | del_timer(&l2cap_pi(sk)->retrans_timer); | ||
2908 | del_timer(&l2cap_pi(sk)->monitor_timer); | ||
2909 | } | ||
2891 | 2910 | ||
2892 | l2cap_chan_del(sk, ECONNRESET); | 2911 | l2cap_chan_del(sk, ECONNRESET); |
2893 | bh_unlock_sock(sk); | 2912 | bh_unlock_sock(sk); |
@@ -2912,9 +2931,12 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd | |||
2912 | return 0; | 2931 | return 0; |
2913 | 2932 | ||
2914 | skb_queue_purge(TX_QUEUE(sk)); | 2933 | skb_queue_purge(TX_QUEUE(sk)); |
2915 | skb_queue_purge(SREJ_QUEUE(sk)); | 2934 | |
2916 | del_timer(&l2cap_pi(sk)->retrans_timer); | 2935 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { |
2917 | del_timer(&l2cap_pi(sk)->monitor_timer); | 2936 | skb_queue_purge(SREJ_QUEUE(sk)); |
2937 | del_timer(&l2cap_pi(sk)->retrans_timer); | ||
2938 | del_timer(&l2cap_pi(sk)->monitor_timer); | ||
2939 | } | ||
2918 | 2940 | ||
2919 | l2cap_chan_del(sk, 0); | 2941 | l2cap_chan_del(sk, 0); |
2920 | bh_unlock_sock(sk); | 2942 | bh_unlock_sock(sk); |
@@ -3279,12 +3301,16 @@ static inline int l2cap_data_channel_iframe(struct sock *sk, u16 rx_control, str | |||
3279 | { | 3301 | { |
3280 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 3302 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
3281 | u8 tx_seq = __get_txseq(rx_control); | 3303 | u8 tx_seq = __get_txseq(rx_control); |
3304 | u8 req_seq = __get_reqseq(rx_control); | ||
3282 | u16 tx_control = 0; | 3305 | u16 tx_control = 0; |
3283 | u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; | 3306 | u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; |
3284 | int err = 0; | 3307 | int err = 0; |
3285 | 3308 | ||
3286 | BT_DBG("sk %p rx_control 0x%4.4x len %d", sk, rx_control, skb->len); | 3309 | BT_DBG("sk %p rx_control 0x%4.4x len %d", sk, rx_control, skb->len); |
3287 | 3310 | ||
3311 | pi->expected_ack_seq = req_seq; | ||
3312 | l2cap_drop_acked_frames(sk); | ||
3313 | |||
3288 | if (tx_seq == pi->expected_tx_seq) | 3314 | if (tx_seq == pi->expected_tx_seq) |
3289 | goto expected; | 3315 | goto expected; |
3290 | 3316 | ||
@@ -3339,6 +3365,16 @@ expected: | |||
3339 | return 0; | 3365 | return 0; |
3340 | } | 3366 | } |
3341 | 3367 | ||
3368 | if (rx_control & L2CAP_CTRL_FINAL) { | ||
3369 | if (pi->conn_state & L2CAP_CONN_REJ_ACT) | ||
3370 | pi->conn_state &= ~L2CAP_CONN_REJ_ACT; | ||
3371 | else { | ||
3372 | sk->sk_send_head = TX_QUEUE(sk)->next; | ||
3373 | pi->next_tx_seq = pi->expected_ack_seq; | ||
3374 | l2cap_ertm_send(sk); | ||
3375 | } | ||
3376 | } | ||
3377 | |||
3342 | pi->buffer_seq = (pi->buffer_seq + 1) % 64; | 3378 | pi->buffer_seq = (pi->buffer_seq + 1) % 64; |
3343 | 3379 | ||
3344 | err = l2cap_sar_reassembly_sdu(sk, skb, rx_control); | 3380 | err = l2cap_sar_reassembly_sdu(sk, skb, rx_control); |
@@ -3375,6 +3411,14 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
3375 | pi->expected_ack_seq = tx_seq; | 3411 | pi->expected_ack_seq = tx_seq; |
3376 | l2cap_drop_acked_frames(sk); | 3412 | l2cap_drop_acked_frames(sk); |
3377 | 3413 | ||
3414 | if (pi->conn_state & L2CAP_CONN_REJ_ACT) | ||
3415 | pi->conn_state &= ~L2CAP_CONN_REJ_ACT; | ||
3416 | else { | ||
3417 | sk->sk_send_head = TX_QUEUE(sk)->next; | ||
3418 | pi->next_tx_seq = pi->expected_ack_seq; | ||
3419 | l2cap_ertm_send(sk); | ||
3420 | } | ||
3421 | |||
3378 | if (!(pi->conn_state & L2CAP_CONN_WAIT_F)) | 3422 | if (!(pi->conn_state & L2CAP_CONN_WAIT_F)) |
3379 | break; | 3423 | break; |
3380 | 3424 | ||
@@ -3387,8 +3431,8 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
3387 | pi->expected_ack_seq = tx_seq; | 3431 | pi->expected_ack_seq = tx_seq; |
3388 | l2cap_drop_acked_frames(sk); | 3432 | l2cap_drop_acked_frames(sk); |
3389 | 3433 | ||
3390 | if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) | 3434 | if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) && |
3391 | && (pi->unacked_frames > 0)) | 3435 | (pi->unacked_frames > 0)) |
3392 | __mod_retrans_timer(); | 3436 | __mod_retrans_timer(); |
3393 | 3437 | ||
3394 | l2cap_ertm_send(sk); | 3438 | l2cap_ertm_send(sk); |
@@ -3402,10 +3446,24 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
3402 | pi->expected_ack_seq = __get_reqseq(rx_control); | 3446 | pi->expected_ack_seq = __get_reqseq(rx_control); |
3403 | l2cap_drop_acked_frames(sk); | 3447 | l2cap_drop_acked_frames(sk); |
3404 | 3448 | ||
3405 | sk->sk_send_head = TX_QUEUE(sk)->next; | 3449 | if (rx_control & L2CAP_CTRL_FINAL) { |
3406 | pi->next_tx_seq = pi->expected_ack_seq; | 3450 | if (pi->conn_state & L2CAP_CONN_REJ_ACT) |
3451 | pi->conn_state &= ~L2CAP_CONN_REJ_ACT; | ||
3452 | else { | ||
3453 | sk->sk_send_head = TX_QUEUE(sk)->next; | ||
3454 | pi->next_tx_seq = pi->expected_ack_seq; | ||
3455 | l2cap_ertm_send(sk); | ||
3456 | } | ||
3457 | } else { | ||
3458 | sk->sk_send_head = TX_QUEUE(sk)->next; | ||
3459 | pi->next_tx_seq = pi->expected_ack_seq; | ||
3460 | l2cap_ertm_send(sk); | ||
3407 | 3461 | ||
3408 | l2cap_ertm_send(sk); | 3462 | if (pi->conn_state & L2CAP_CONN_WAIT_F) { |
3463 | pi->srej_save_reqseq = tx_seq; | ||
3464 | pi->conn_state |= L2CAP_CONN_REJ_ACT; | ||
3465 | } | ||
3466 | } | ||
3409 | 3467 | ||
3410 | break; | 3468 | break; |
3411 | 3469 | ||
@@ -3424,7 +3482,7 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str | |||
3424 | } else if (rx_control & L2CAP_CTRL_FINAL) { | 3482 | } else if (rx_control & L2CAP_CTRL_FINAL) { |
3425 | if ((pi->conn_state & L2CAP_CONN_SREJ_ACT) && | 3483 | if ((pi->conn_state & L2CAP_CONN_SREJ_ACT) && |
3426 | pi->srej_save_reqseq == tx_seq) | 3484 | pi->srej_save_reqseq == tx_seq) |
3427 | pi->srej_save_reqseq &= ~L2CAP_CONN_SREJ_ACT; | 3485 | pi->conn_state &= ~L2CAP_CONN_SREJ_ACT; |
3428 | else | 3486 | else |
3429 | l2cap_retransmit_frame(sk, tx_seq); | 3487 | l2cap_retransmit_frame(sk, tx_seq); |
3430 | } | 3488 | } |
@@ -3924,7 +3982,7 @@ static const struct proto_ops l2cap_sock_ops = { | |||
3924 | .getsockopt = l2cap_sock_getsockopt | 3982 | .getsockopt = l2cap_sock_getsockopt |
3925 | }; | 3983 | }; |
3926 | 3984 | ||
3927 | static struct net_proto_family l2cap_sock_family_ops = { | 3985 | static const struct net_proto_family l2cap_sock_family_ops = { |
3928 | .family = PF_BLUETOOTH, | 3986 | .family = PF_BLUETOOTH, |
3929 | .owner = THIS_MODULE, | 3987 | .owner = THIS_MODULE, |
3930 | .create = l2cap_sock_create, | 3988 | .create = l2cap_sock_create, |
@@ -4003,6 +4061,9 @@ module_exit(l2cap_exit); | |||
4003 | module_param(enable_ertm, bool, 0644); | 4061 | module_param(enable_ertm, bool, 0644); |
4004 | MODULE_PARM_DESC(enable_ertm, "Enable enhanced retransmission mode"); | 4062 | MODULE_PARM_DESC(enable_ertm, "Enable enhanced retransmission mode"); |
4005 | 4063 | ||
4064 | module_param(max_transmit, uint, 0644); | ||
4065 | MODULE_PARM_DESC(max_transmit, "Max transmit value (default = 3)"); | ||
4066 | |||
4006 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); | 4067 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
4007 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); | 4068 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); |
4008 | MODULE_VERSION(VERSION); | 4069 | MODULE_VERSION(VERSION); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 25692bc0a342..fc5ee3296e22 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -51,6 +51,7 @@ | |||
51 | static int disable_cfc = 0; | 51 | static int disable_cfc = 0; |
52 | static int channel_mtu = -1; | 52 | static int channel_mtu = -1; |
53 | static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; | 53 | static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; |
54 | static int l2cap_ertm = 0; | ||
54 | 55 | ||
55 | static struct task_struct *rfcomm_thread; | 56 | static struct task_struct *rfcomm_thread; |
56 | 57 | ||
@@ -702,6 +703,8 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst | |||
702 | sk = sock->sk; | 703 | sk = sock->sk; |
703 | lock_sock(sk); | 704 | lock_sock(sk); |
704 | l2cap_pi(sk)->imtu = l2cap_mtu; | 705 | l2cap_pi(sk)->imtu = l2cap_mtu; |
706 | if (l2cap_ertm) | ||
707 | l2cap_pi(sk)->mode = L2CAP_MODE_ERTM; | ||
705 | release_sock(sk); | 708 | release_sock(sk); |
706 | 709 | ||
707 | s = rfcomm_session_add(sock, BT_BOUND); | 710 | s = rfcomm_session_add(sock, BT_BOUND); |
@@ -2185,6 +2188,9 @@ MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel"); | |||
2185 | module_param(l2cap_mtu, uint, 0644); | 2188 | module_param(l2cap_mtu, uint, 0644); |
2186 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); | 2189 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); |
2187 | 2190 | ||
2191 | module_param(l2cap_ertm, bool, 0644); | ||
2192 | MODULE_PARM_DESC(l2cap_ertm, "Use L2CAP ERTM mode for connection"); | ||
2193 | |||
2188 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); | 2194 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
2189 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); | 2195 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); |
2190 | MODULE_VERSION(VERSION); | 2196 | MODULE_VERSION(VERSION); |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 8a20aaf1f231..4b5968dda673 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -323,7 +323,8 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
323 | return sk; | 323 | return sk; |
324 | } | 324 | } |
325 | 325 | ||
326 | static int rfcomm_sock_create(struct net *net, struct socket *sock, int protocol) | 326 | static int rfcomm_sock_create(struct net *net, struct socket *sock, |
327 | int protocol, int kern) | ||
327 | { | 328 | { |
328 | struct sock *sk; | 329 | struct sock *sk; |
329 | 330 | ||
@@ -703,7 +704,7 @@ static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
703 | copied += chunk; | 704 | copied += chunk; |
704 | size -= chunk; | 705 | size -= chunk; |
705 | 706 | ||
706 | sock_recv_timestamp(msg, sk, skb); | 707 | sock_recv_ts_and_drops(msg, sk, skb); |
707 | 708 | ||
708 | if (!(flags & MSG_PEEK)) { | 709 | if (!(flags & MSG_PEEK)) { |
709 | atomic_sub(chunk, &sk->sk_rmem_alloc); | 710 | atomic_sub(chunk, &sk->sk_rmem_alloc); |
@@ -1101,7 +1102,7 @@ static const struct proto_ops rfcomm_sock_ops = { | |||
1101 | .mmap = sock_no_mmap | 1102 | .mmap = sock_no_mmap |
1102 | }; | 1103 | }; |
1103 | 1104 | ||
1104 | static struct net_proto_family rfcomm_sock_family_ops = { | 1105 | static const struct net_proto_family rfcomm_sock_family_ops = { |
1105 | .family = PF_BLUETOOTH, | 1106 | .family = PF_BLUETOOTH, |
1106 | .owner = THIS_MODULE, | 1107 | .owner = THIS_MODULE, |
1107 | .create = rfcomm_sock_create | 1108 | .create = rfcomm_sock_create |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 77f4153bdb5e..dd8f6ec57dce 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -430,7 +430,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro | |||
430 | return sk; | 430 | return sk; |
431 | } | 431 | } |
432 | 432 | ||
433 | static int sco_sock_create(struct net *net, struct socket *sock, int protocol) | 433 | static int sco_sock_create(struct net *net, struct socket *sock, int protocol, |
434 | int kern) | ||
434 | { | 435 | { |
435 | struct sock *sk; | 436 | struct sock *sk; |
436 | 437 | ||
@@ -993,7 +994,7 @@ static const struct proto_ops sco_sock_ops = { | |||
993 | .getsockopt = sco_sock_getsockopt | 994 | .getsockopt = sco_sock_getsockopt |
994 | }; | 995 | }; |
995 | 996 | ||
996 | static struct net_proto_family sco_sock_family_ops = { | 997 | static const struct net_proto_family sco_sock_family_ops = { |
997 | .family = PF_BLUETOOTH, | 998 | .family = PF_BLUETOOTH, |
998 | .owner = THIS_MODULE, | 999 | .owner = THIS_MODULE, |
999 | .create = sco_sock_create, | 1000 | .create = sco_sock_create, |