aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/l2cap_core.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b52f66d22437..f7ee037c7934 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -53,8 +53,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
53static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, 53static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
54 void *data); 54 void *data);
55static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); 55static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data);
56static void l2cap_send_disconn_req(struct l2cap_conn *conn, 56static void l2cap_send_disconn_req(struct l2cap_chan *chan, int err);
57 struct l2cap_chan *chan, int err);
58 57
59static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, 58static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
60 struct sk_buff_head *skbs, u8 event); 59 struct sk_buff_head *skbs, u8 event);
@@ -632,7 +631,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
632 if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && 631 if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED &&
633 conn->hcon->type == ACL_LINK) { 632 conn->hcon->type == ACL_LINK) {
634 __set_chan_timer(chan, sk->sk_sndtimeo); 633 __set_chan_timer(chan, sk->sk_sndtimeo);
635 l2cap_send_disconn_req(conn, chan, reason); 634 l2cap_send_disconn_req(chan, reason);
636 } else 635 } else
637 l2cap_chan_del(chan, reason); 636 l2cap_chan_del(chan, reason);
638 break; 637 break;
@@ -1180,10 +1179,10 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
1180 } 1179 }
1181} 1180}
1182 1181
1183static void l2cap_send_disconn_req(struct l2cap_conn *conn, 1182static void l2cap_send_disconn_req(struct l2cap_chan *chan, int err)
1184 struct l2cap_chan *chan, int err)
1185{ 1183{
1186 struct sock *sk = chan->sk; 1184 struct sock *sk = chan->sk;
1185 struct l2cap_conn *conn = chan->conn;
1187 struct l2cap_disconn_req req; 1186 struct l2cap_disconn_req req;
1188 1187
1189 if (!conn) 1188 if (!conn)
@@ -1960,7 +1959,7 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan)
1960 if (chan->max_tx != 0 && 1959 if (chan->max_tx != 0 &&
1961 bt_cb(skb)->control.retries > chan->max_tx) { 1960 bt_cb(skb)->control.retries > chan->max_tx) {
1962 BT_DBG("Retry limit exceeded (%d)", chan->max_tx); 1961 BT_DBG("Retry limit exceeded (%d)", chan->max_tx);
1963 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 1962 l2cap_send_disconn_req(chan, ECONNRESET);
1964 l2cap_seq_list_clear(&chan->retrans_list); 1963 l2cap_seq_list_clear(&chan->retrans_list);
1965 break; 1964 break;
1966 } 1965 }
@@ -2666,7 +2665,7 @@ static void l2cap_tx_state_wait_f(struct l2cap_chan *chan,
2666 __set_monitor_timer(chan); 2665 __set_monitor_timer(chan);
2667 chan->retry_count++; 2666 chan->retry_count++;
2668 } else { 2667 } else {
2669 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED); 2668 l2cap_send_disconn_req(chan, ECONNABORTED);
2670 } 2669 }
2671 break; 2670 break;
2672 default: 2671 default:
@@ -3877,7 +3876,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3877 /* Complete config. */ 3876 /* Complete config. */
3878 len = l2cap_parse_conf_req(chan, rsp); 3877 len = l2cap_parse_conf_req(chan, rsp);
3879 if (len < 0) { 3878 if (len < 0) {
3880 l2cap_send_disconn_req(conn, chan, ECONNRESET); 3879 l2cap_send_disconn_req(chan, ECONNRESET);
3881 goto unlock; 3880 goto unlock;
3882 } 3881 }
3883 3882
@@ -3899,7 +3898,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3899 err = l2cap_ertm_init(chan); 3898 err = l2cap_ertm_init(chan);
3900 3899
3901 if (err < 0) 3900 if (err < 0)
3902 l2cap_send_disconn_req(chan->conn, chan, -err); 3901 l2cap_send_disconn_req(chan, -err);
3903 else 3902 else
3904 l2cap_chan_ready(chan); 3903 l2cap_chan_ready(chan);
3905 3904
@@ -3967,7 +3966,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
3967 len = l2cap_parse_conf_rsp(chan, rsp->data, len, 3966 len = l2cap_parse_conf_rsp(chan, rsp->data, len,
3968 buf, &result); 3967 buf, &result);
3969 if (len < 0) { 3968 if (len < 0) {
3970 l2cap_send_disconn_req(conn, chan, ECONNRESET); 3969 l2cap_send_disconn_req(chan, ECONNRESET);
3971 goto done; 3970 goto done;
3972 } 3971 }
3973 3972
@@ -3988,7 +3987,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
3988 char req[64]; 3987 char req[64];
3989 3988
3990 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { 3989 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) {
3991 l2cap_send_disconn_req(conn, chan, ECONNRESET); 3990 l2cap_send_disconn_req(chan, ECONNRESET);
3992 goto done; 3991 goto done;
3993 } 3992 }
3994 3993
@@ -3997,7 +3996,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
3997 len = l2cap_parse_conf_rsp(chan, rsp->data, len, 3996 len = l2cap_parse_conf_rsp(chan, rsp->data, len,
3998 req, &result); 3997 req, &result);
3999 if (len < 0) { 3998 if (len < 0) {
4000 l2cap_send_disconn_req(conn, chan, ECONNRESET); 3999 l2cap_send_disconn_req(chan, ECONNRESET);
4001 goto done; 4000 goto done;
4002 } 4001 }
4003 4002
@@ -4013,7 +4012,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
4013 l2cap_chan_set_err(chan, ECONNRESET); 4012 l2cap_chan_set_err(chan, ECONNRESET);
4014 4013
4015 __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); 4014 __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT);
4016 l2cap_send_disconn_req(conn, chan, ECONNRESET); 4015 l2cap_send_disconn_req(chan, ECONNRESET);
4017 goto done; 4016 goto done;
4018 } 4017 }
4019 4018
@@ -4030,7 +4029,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
4030 err = l2cap_ertm_init(chan); 4029 err = l2cap_ertm_init(chan);
4031 4030
4032 if (err < 0) 4031 if (err < 0)
4033 l2cap_send_disconn_req(chan->conn, chan, -err); 4032 l2cap_send_disconn_req(chan, -err);
4034 else 4033 else
4035 l2cap_chan_ready(chan); 4034 l2cap_chan_ready(chan);
4036 } 4035 }
@@ -4392,7 +4391,7 @@ static void l2cap_logical_fail(struct l2cap_chan *chan)
4392 /* Logical link setup failed */ 4391 /* Logical link setup failed */
4393 if (chan->state != BT_CONNECTED) { 4392 if (chan->state != BT_CONNECTED) {
4394 /* Create channel failure, disconnect */ 4393 /* Create channel failure, disconnect */
4395 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 4394 l2cap_send_disconn_req(chan, ECONNRESET);
4396 return; 4395 return;
4397 } 4396 }
4398 4397
@@ -4435,7 +4434,7 @@ static void l2cap_logical_finish_create(struct l2cap_chan *chan,
4435 4434
4436 err = l2cap_ertm_init(chan); 4435 err = l2cap_ertm_init(chan);
4437 if (err < 0) 4436 if (err < 0)
4438 l2cap_send_disconn_req(chan->conn, chan, -err); 4437 l2cap_send_disconn_req(chan, -err);
4439 else 4438 else
4440 l2cap_chan_ready(chan); 4439 l2cap_chan_ready(chan);
4441 } 4440 }
@@ -5400,7 +5399,7 @@ static void l2cap_handle_srej(struct l2cap_chan *chan,
5400 5399
5401 if (control->reqseq == chan->next_tx_seq) { 5400 if (control->reqseq == chan->next_tx_seq) {
5402 BT_DBG("Invalid reqseq %d, disconnecting", control->reqseq); 5401 BT_DBG("Invalid reqseq %d, disconnecting", control->reqseq);
5403 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 5402 l2cap_send_disconn_req(chan, ECONNRESET);
5404 return; 5403 return;
5405 } 5404 }
5406 5405
@@ -5414,7 +5413,7 @@ static void l2cap_handle_srej(struct l2cap_chan *chan,
5414 5413
5415 if (chan->max_tx != 0 && bt_cb(skb)->control.retries >= chan->max_tx) { 5414 if (chan->max_tx != 0 && bt_cb(skb)->control.retries >= chan->max_tx) {
5416 BT_DBG("Retry limit exceeded (%d)", chan->max_tx); 5415 BT_DBG("Retry limit exceeded (%d)", chan->max_tx);
5417 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 5416 l2cap_send_disconn_req(chan, ECONNRESET);
5418 return; 5417 return;
5419 } 5418 }
5420 5419
@@ -5458,7 +5457,7 @@ static void l2cap_handle_rej(struct l2cap_chan *chan,
5458 5457
5459 if (control->reqseq == chan->next_tx_seq) { 5458 if (control->reqseq == chan->next_tx_seq) {
5460 BT_DBG("Invalid reqseq %d, disconnecting", control->reqseq); 5459 BT_DBG("Invalid reqseq %d, disconnecting", control->reqseq);
5461 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 5460 l2cap_send_disconn_req(chan, ECONNRESET);
5462 return; 5461 return;
5463 } 5462 }
5464 5463
@@ -5467,7 +5466,7 @@ static void l2cap_handle_rej(struct l2cap_chan *chan,
5467 if (chan->max_tx && skb && 5466 if (chan->max_tx && skb &&
5468 bt_cb(skb)->control.retries >= chan->max_tx) { 5467 bt_cb(skb)->control.retries >= chan->max_tx) {
5469 BT_DBG("Retry limit exceeded (%d)", chan->max_tx); 5468 BT_DBG("Retry limit exceeded (%d)", chan->max_tx);
5470 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 5469 l2cap_send_disconn_req(chan, ECONNRESET);
5471 return; 5470 return;
5472 } 5471 }
5473 5472
@@ -5651,8 +5650,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
5651 break; 5650 break;
5652 case L2CAP_TXSEQ_INVALID: 5651 case L2CAP_TXSEQ_INVALID:
5653 default: 5652 default:
5654 l2cap_send_disconn_req(chan->conn, chan, 5653 l2cap_send_disconn_req(chan, ECONNRESET);
5655 ECONNRESET);
5656 break; 5654 break;
5657 } 5655 }
5658 break; 5656 break;
@@ -5785,8 +5783,7 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan,
5785 break; 5783 break;
5786 case L2CAP_TXSEQ_INVALID: 5784 case L2CAP_TXSEQ_INVALID:
5787 default: 5785 default:
5788 l2cap_send_disconn_req(chan->conn, chan, 5786 l2cap_send_disconn_req(chan, ECONNRESET);
5789 ECONNRESET);
5790 break; 5787 break;
5791 } 5788 }
5792 break; 5789 break;
@@ -5981,7 +5978,7 @@ static int l2cap_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
5981 BT_DBG("Invalid reqseq %d (next_tx_seq %d, expected_ack_seq %d", 5978 BT_DBG("Invalid reqseq %d (next_tx_seq %d, expected_ack_seq %d",
5982 control->reqseq, chan->next_tx_seq, 5979 control->reqseq, chan->next_tx_seq,
5983 chan->expected_ack_seq); 5980 chan->expected_ack_seq);
5984 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 5981 l2cap_send_disconn_req(chan, ECONNRESET);
5985 } 5982 }
5986 5983
5987 return err; 5984 return err;
@@ -6050,7 +6047,7 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
6050 len -= L2CAP_FCS_SIZE; 6047 len -= L2CAP_FCS_SIZE;
6051 6048
6052 if (len > chan->mps) { 6049 if (len > chan->mps) {
6053 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 6050 l2cap_send_disconn_req(chan, ECONNRESET);
6054 goto drop; 6051 goto drop;
6055 } 6052 }
6056 6053
@@ -6075,8 +6072,7 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
6075 } 6072 }
6076 6073
6077 if (err) 6074 if (err)
6078 l2cap_send_disconn_req(chan->conn, chan, 6075 l2cap_send_disconn_req(chan, ECONNRESET);
6079 ECONNRESET);
6080 } else { 6076 } else {
6081 const u8 rx_func_to_event[4] = { 6077 const u8 rx_func_to_event[4] = {
6082 L2CAP_EV_RECV_RR, L2CAP_EV_RECV_REJ, 6078 L2CAP_EV_RECV_RR, L2CAP_EV_RECV_REJ,
@@ -6093,7 +6089,7 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
6093 6089
6094 if (len != 0) { 6090 if (len != 0) {
6095 BT_ERR("Trailing bytes: %d in sframe", len); 6091 BT_ERR("Trailing bytes: %d in sframe", len);
6096 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 6092 l2cap_send_disconn_req(chan, ECONNRESET);
6097 goto drop; 6093 goto drop;
6098 } 6094 }
6099 6095
@@ -6104,7 +6100,7 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
6104 6100
6105 event = rx_func_to_event[control->super]; 6101 event = rx_func_to_event[control->super];
6106 if (l2cap_rx(chan, control, skb, event)) 6102 if (l2cap_rx(chan, control, skb, event))
6107 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 6103 l2cap_send_disconn_req(chan, ECONNRESET);
6108 } 6104 }
6109 6105
6110 return 0; 6106 return 0;