diff options
-rw-r--r-- | include/net/bluetooth/l2cap.h | 3 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 35 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 31 |
3 files changed, 35 insertions, 34 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 336b2af758b3..c9df0ef5b6f5 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -434,8 +434,10 @@ void l2cap_cleanup_sockets(void); | |||
434 | u8 l2cap_get_ident(struct l2cap_conn *conn); | 434 | u8 l2cap_get_ident(struct l2cap_conn *conn); |
435 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | 435 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); |
436 | int l2cap_build_conf_req(struct sock *sk, void *data); | 436 | int l2cap_build_conf_req(struct sock *sk, void *data); |
437 | int __l2cap_wait_ack(struct sock *sk); | ||
437 | 438 | ||
438 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | 439 | void l2cap_sock_set_timer(struct sock *sk, long timeout); |
440 | void l2cap_sock_clear_timer(struct sock *sk); | ||
439 | void __l2cap_sock_close(struct sock *sk, int reason); | 441 | void __l2cap_sock_close(struct sock *sk, int reason); |
440 | void l2cap_sock_kill(struct sock *sk); | 442 | void l2cap_sock_kill(struct sock *sk); |
441 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | 443 | void l2cap_sock_init(struct sock *sk, struct sock *parent); |
@@ -444,7 +446,6 @@ struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | |||
444 | int l2cap_do_connect(struct sock *sk); | 446 | int l2cap_do_connect(struct sock *sk); |
445 | 447 | ||
446 | int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len); | 448 | int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len); |
447 | int l2cap_sock_shutdown(struct socket *sock, int how); | ||
448 | 449 | ||
449 | 450 | ||
450 | void l2cap_load(void); | 451 | void l2cap_load(void); |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3a0e42be89ea..6e48e580555e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -84,7 +84,7 @@ void l2cap_sock_set_timer(struct sock *sk, long timeout) | |||
84 | sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); | 84 | sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void l2cap_sock_clear_timer(struct sock *sk) | 87 | void l2cap_sock_clear_timer(struct sock *sk) |
88 | { | 88 | { |
89 | BT_DBG("sock %p state %d", sk, sk->sk_state); | 89 | BT_DBG("sock %p state %d", sk, sk->sk_state); |
90 | sk_stop_timer(sk, &sk->sk_timer); | 90 | sk_stop_timer(sk, &sk->sk_timer); |
@@ -907,7 +907,7 @@ done: | |||
907 | return err; | 907 | return err; |
908 | } | 908 | } |
909 | 909 | ||
910 | static int __l2cap_wait_ack(struct sock *sk) | 910 | int __l2cap_wait_ack(struct sock *sk) |
911 | { | 911 | { |
912 | DECLARE_WAITQUEUE(wait, current); | 912 | DECLARE_WAITQUEUE(wait, current); |
913 | int err = 0; | 913 | int err = 0; |
@@ -1468,37 +1468,6 @@ done: | |||
1468 | return err; | 1468 | return err; |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | int l2cap_sock_shutdown(struct socket *sock, int how) | ||
1472 | { | ||
1473 | struct sock *sk = sock->sk; | ||
1474 | int err = 0; | ||
1475 | |||
1476 | BT_DBG("sock %p, sk %p", sock, sk); | ||
1477 | |||
1478 | if (!sk) | ||
1479 | return 0; | ||
1480 | |||
1481 | lock_sock(sk); | ||
1482 | if (!sk->sk_shutdown) { | ||
1483 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | ||
1484 | err = __l2cap_wait_ack(sk); | ||
1485 | |||
1486 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
1487 | l2cap_sock_clear_timer(sk); | ||
1488 | __l2cap_sock_close(sk, 0); | ||
1489 | |||
1490 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | ||
1491 | err = bt_sock_wait_state(sk, BT_CLOSED, | ||
1492 | sk->sk_lingertime); | ||
1493 | } | ||
1494 | |||
1495 | if (!err && sk->sk_err) | ||
1496 | err = -sk->sk_err; | ||
1497 | |||
1498 | release_sock(sk); | ||
1499 | return err; | ||
1500 | } | ||
1501 | |||
1502 | static void l2cap_chan_ready(struct sock *sk) | 1471 | static void l2cap_chan_ready(struct sock *sk) |
1503 | { | 1472 | { |
1504 | struct sock *parent = bt_sk(sk)->parent; | 1473 | struct sock *parent = bt_sk(sk)->parent; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index fa2bc5d85560..93af233bb167 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -723,6 +723,37 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
723 | return bt_sock_recvmsg(iocb, sock, msg, len, flags); | 723 | return bt_sock_recvmsg(iocb, sock, msg, len, flags); |
724 | } | 724 | } |
725 | 725 | ||
726 | static int l2cap_sock_shutdown(struct socket *sock, int how) | ||
727 | { | ||
728 | struct sock *sk = sock->sk; | ||
729 | int err = 0; | ||
730 | |||
731 | BT_DBG("sock %p, sk %p", sock, sk); | ||
732 | |||
733 | if (!sk) | ||
734 | return 0; | ||
735 | |||
736 | lock_sock(sk); | ||
737 | if (!sk->sk_shutdown) { | ||
738 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | ||
739 | err = __l2cap_wait_ack(sk); | ||
740 | |||
741 | sk->sk_shutdown = SHUTDOWN_MASK; | ||
742 | l2cap_sock_clear_timer(sk); | ||
743 | __l2cap_sock_close(sk, 0); | ||
744 | |||
745 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | ||
746 | err = bt_sock_wait_state(sk, BT_CLOSED, | ||
747 | sk->sk_lingertime); | ||
748 | } | ||
749 | |||
750 | if (!err && sk->sk_err) | ||
751 | err = -sk->sk_err; | ||
752 | |||
753 | release_sock(sk); | ||
754 | return err; | ||
755 | } | ||
756 | |||
726 | static int l2cap_sock_release(struct socket *sock) | 757 | static int l2cap_sock_release(struct socket *sock) |
727 | { | 758 | { |
728 | struct sock *sk = sock->sk; | 759 | struct sock *sk = sock->sk; |