aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-03-31 23:53:45 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-07 17:06:27 -0400
commite92c8e70faf5e3cc22979daba2a895359aa1eab2 (patch)
treec9d5ec9debd76903cb5770551ad7aa1e92eff867 /net
parent2c03a7a49e0831646bd35d0877ec7d051d8f174b (diff)
Bluetooth: Move ERTM timers to struct l2cap_chan
This also triggered a change in l2cap_send_disconn_req() parameters. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_core.c74
-rw-r--r--net/bluetooth/l2cap_sock.c13
2 files changed, 43 insertions, 44 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2176a003087e..eaac13cb7932 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -241,9 +241,9 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
241 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { 241 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
242 struct srej_list *l, *tmp; 242 struct srej_list *l, *tmp;
243 243
244 del_timer(&l2cap_pi(sk)->retrans_timer); 244 del_timer(&chan->retrans_timer);
245 del_timer(&l2cap_pi(sk)->monitor_timer); 245 del_timer(&chan->monitor_timer);
246 del_timer(&l2cap_pi(sk)->ack_timer); 246 del_timer(&chan->ack_timer);
247 247
248 skb_queue_purge(SREJ_QUEUE(sk)); 248 skb_queue_purge(SREJ_QUEUE(sk));
249 skb_queue_purge(BUSY_QUEUE(sk)); 249 skb_queue_purge(BUSY_QUEUE(sk));
@@ -462,19 +462,22 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask)
462 } 462 }
463} 463}
464 464
465void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err) 465void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err)
466{ 466{
467 struct sock *sk;
467 struct l2cap_disconn_req req; 468 struct l2cap_disconn_req req;
468 469
469 if (!conn) 470 if (!conn)
470 return; 471 return;
471 472
473 sk = chan->sk;
474
472 skb_queue_purge(TX_QUEUE(sk)); 475 skb_queue_purge(TX_QUEUE(sk));
473 476
474 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { 477 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) {
475 del_timer(&l2cap_pi(sk)->retrans_timer); 478 del_timer(&chan->retrans_timer);
476 del_timer(&l2cap_pi(sk)->monitor_timer); 479 del_timer(&chan->monitor_timer);
477 del_timer(&l2cap_pi(sk)->ack_timer); 480 del_timer(&chan->ack_timer);
478 } 481 }
479 482
480 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid); 483 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
@@ -957,7 +960,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
957 960
958 bh_lock_sock(sk); 961 bh_lock_sock(sk);
959 if (chan->retry_count >= chan->remote_max_tx) { 962 if (chan->retry_count >= chan->remote_max_tx) {
960 l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk, ECONNABORTED); 963 l2cap_send_disconn_req(l2cap_pi(sk)->conn, chan, ECONNABORTED);
961 bh_unlock_sock(sk); 964 bh_unlock_sock(sk);
962 return; 965 return;
963 } 966 }
@@ -1003,7 +1006,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
1003 } 1006 }
1004 1007
1005 if (!chan->unacked_frames) 1008 if (!chan->unacked_frames)
1006 del_timer(&l2cap_pi(sk)->retrans_timer); 1009 del_timer(&chan->retrans_timer);
1007} 1010}
1008 1011
1009void l2cap_do_send(struct sock *sk, struct sk_buff *skb) 1012void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
@@ -1067,7 +1070,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1067 1070
1068 if (chan->remote_max_tx && 1071 if (chan->remote_max_tx &&
1069 bt_cb(skb)->retries == chan->remote_max_tx) { 1072 bt_cb(skb)->retries == chan->remote_max_tx) {
1070 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED); 1073 l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED);
1071 return; 1074 return;
1072 } 1075 }
1073 1076
@@ -1108,7 +1111,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1108 1111
1109 if (chan->remote_max_tx && 1112 if (chan->remote_max_tx &&
1110 bt_cb(skb)->retries == chan->remote_max_tx) { 1113 bt_cb(skb)->retries == chan->remote_max_tx) {
1111 l2cap_send_disconn_req(pi->conn, sk, ECONNABORTED); 1114 l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED);
1112 break; 1115 break;
1113 } 1116 }
1114 1117
@@ -1579,12 +1582,11 @@ static inline void l2cap_ertm_init(struct l2cap_chan *chan)
1579 chan->num_acked = 0; 1582 chan->num_acked = 0;
1580 chan->frames_sent = 0; 1583 chan->frames_sent = 0;
1581 1584
1582 setup_timer(&l2cap_pi(sk)->retrans_timer, 1585 setup_timer(&chan->retrans_timer, l2cap_retrans_timeout,
1583 l2cap_retrans_timeout, (unsigned long) chan); 1586 (unsigned long) chan);
1584 setup_timer(&l2cap_pi(sk)->monitor_timer, 1587 setup_timer(&chan->monitor_timer, l2cap_monitor_timeout,
1585 l2cap_monitor_timeout, (unsigned long) chan); 1588 (unsigned long) chan);
1586 setup_timer(&l2cap_pi(sk)->ack_timer, 1589 setup_timer(&chan->ack_timer, l2cap_ack_timeout, (unsigned long) chan);
1587 l2cap_ack_timeout, (unsigned long) chan);
1588 1590
1589 __skb_queue_head_init(SREJ_QUEUE(sk)); 1591 __skb_queue_head_init(SREJ_QUEUE(sk));
1590 __skb_queue_head_init(BUSY_QUEUE(sk)); 1592 __skb_queue_head_init(BUSY_QUEUE(sk));
@@ -2291,7 +2293,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2291 /* Complete config. */ 2293 /* Complete config. */
2292 len = l2cap_parse_conf_req(chan, rsp); 2294 len = l2cap_parse_conf_req(chan, rsp);
2293 if (len < 0) { 2295 if (len < 0) {
2294 l2cap_send_disconn_req(conn, sk, ECONNRESET); 2296 l2cap_send_disconn_req(conn, chan, ECONNRESET);
2295 goto unlock; 2297 goto unlock;
2296 } 2298 }
2297 2299
@@ -2363,7 +2365,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2363 char req[64]; 2365 char req[64];
2364 2366
2365 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { 2367 if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) {
2366 l2cap_send_disconn_req(conn, sk, ECONNRESET); 2368 l2cap_send_disconn_req(conn, chan, ECONNRESET);
2367 goto done; 2369 goto done;
2368 } 2370 }
2369 2371
@@ -2372,7 +2374,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2372 len = l2cap_parse_conf_rsp(sk, rsp->data, 2374 len = l2cap_parse_conf_rsp(sk, rsp->data,
2373 len, req, &result); 2375 len, req, &result);
2374 if (len < 0) { 2376 if (len < 0) {
2375 l2cap_send_disconn_req(conn, sk, ECONNRESET); 2377 l2cap_send_disconn_req(conn, chan, ECONNRESET);
2376 goto done; 2378 goto done;
2377 } 2379 }
2378 2380
@@ -2387,7 +2389,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2387 default: 2389 default:
2388 sk->sk_err = ECONNRESET; 2390 sk->sk_err = ECONNRESET;
2389 l2cap_sock_set_timer(sk, HZ * 5); 2391 l2cap_sock_set_timer(sk, HZ * 5);
2390 l2cap_send_disconn_req(conn, sk, ECONNRESET); 2392 l2cap_send_disconn_req(conn, chan, ECONNRESET);
2391 goto done; 2393 goto done;
2392 } 2394 }
2393 2395
@@ -2957,7 +2959,7 @@ drop:
2957 chan->sdu = NULL; 2959 chan->sdu = NULL;
2958 2960
2959disconnect: 2961disconnect:
2960 l2cap_send_disconn_req(pi->conn, chan->sk, ECONNRESET); 2962 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
2961 kfree_skb(skb); 2963 kfree_skb(skb);
2962 return 0; 2964 return 0;
2963} 2965}
@@ -2965,7 +2967,6 @@ disconnect:
2965static int l2cap_try_push_rx_skb(struct l2cap_chan *chan) 2967static int l2cap_try_push_rx_skb(struct l2cap_chan *chan)
2966{ 2968{
2967 struct sock *sk = chan->sk; 2969 struct sock *sk = chan->sk;
2968 struct l2cap_pinfo *pi = l2cap_pi(sk);
2969 struct sk_buff *skb; 2970 struct sk_buff *skb;
2970 u16 control; 2971 u16 control;
2971 int err; 2972 int err;
@@ -2989,7 +2990,7 @@ static int l2cap_try_push_rx_skb(struct l2cap_chan *chan)
2989 l2cap_send_sframe(chan, control); 2990 l2cap_send_sframe(chan, control);
2990 chan->retry_count = 1; 2991 chan->retry_count = 1;
2991 2992
2992 del_timer(&pi->retrans_timer); 2993 del_timer(&chan->retrans_timer);
2993 __mod_monitor_timer(); 2994 __mod_monitor_timer();
2994 2995
2995 chan->conn_state |= L2CAP_CONN_WAIT_F; 2996 chan->conn_state |= L2CAP_CONN_WAIT_F;
@@ -3020,7 +3021,7 @@ static void l2cap_busy_work(struct work_struct *work)
3020 3021
3021 if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) { 3022 if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) {
3022 err = -EBUSY; 3023 err = -EBUSY;
3023 l2cap_send_disconn_req(pi->conn, sk, EBUSY); 3024 l2cap_send_disconn_req(pi->conn, pi->chan, EBUSY);
3024 break; 3025 break;
3025 } 3026 }
3026 3027
@@ -3083,7 +3084,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c
3083 3084
3084 chan->conn_state |= L2CAP_CONN_RNR_SENT; 3085 chan->conn_state |= L2CAP_CONN_RNR_SENT;
3085 3086
3086 del_timer(&pi->ack_timer); 3087 del_timer(&chan->ack_timer);
3087 3088
3088 queue_work(_busy_wq, &pi->busy_work); 3089 queue_work(_busy_wq, &pi->busy_work);
3089 3090
@@ -3258,7 +3259,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3258 3259
3259 if (L2CAP_CTRL_FINAL & rx_control && 3260 if (L2CAP_CTRL_FINAL & rx_control &&
3260 chan->conn_state & L2CAP_CONN_WAIT_F) { 3261 chan->conn_state & L2CAP_CONN_WAIT_F) {
3261 del_timer(&pi->monitor_timer); 3262 del_timer(&chan->monitor_timer);
3262 if (chan->unacked_frames > 0) 3263 if (chan->unacked_frames > 0)
3263 __mod_retrans_timer(); 3264 __mod_retrans_timer();
3264 chan->conn_state &= ~L2CAP_CONN_WAIT_F; 3265 chan->conn_state &= ~L2CAP_CONN_WAIT_F;
@@ -3276,7 +3277,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3276 3277
3277 /* invalid tx_seq */ 3278 /* invalid tx_seq */
3278 if (tx_seq_offset >= pi->tx_win) { 3279 if (tx_seq_offset >= pi->tx_win) {
3279 l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); 3280 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
3280 goto drop; 3281 goto drop;
3281 } 3282 }
3282 3283
@@ -3341,7 +3342,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3341 3342
3342 l2cap_send_srejframe(chan, tx_seq); 3343 l2cap_send_srejframe(chan, tx_seq);
3343 3344
3344 del_timer(&pi->ack_timer); 3345 del_timer(&chan->ack_timer);
3345 } 3346 }
3346 return 0; 3347 return 0;
3347 3348
@@ -3484,7 +3485,6 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_
3484 3485
3485static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control) 3486static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control)
3486{ 3487{
3487 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
3488 u8 tx_seq = __get_reqseq(rx_control); 3488 u8 tx_seq = __get_reqseq(rx_control);
3489 3489
3490 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3490 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
@@ -3497,7 +3497,7 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
3497 chan->conn_state |= L2CAP_CONN_SEND_FBIT; 3497 chan->conn_state |= L2CAP_CONN_SEND_FBIT;
3498 3498
3499 if (!(chan->conn_state & L2CAP_CONN_SREJ_SENT)) { 3499 if (!(chan->conn_state & L2CAP_CONN_SREJ_SENT)) {
3500 del_timer(&pi->retrans_timer); 3500 del_timer(&chan->retrans_timer);
3501 if (rx_control & L2CAP_CTRL_POLL) 3501 if (rx_control & L2CAP_CTRL_POLL)
3502 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL); 3502 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL);
3503 return; 3503 return;
@@ -3511,13 +3511,11 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
3511 3511
3512static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3512static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
3513{ 3513{
3514 struct sock *sk = chan->sk;
3515
3516 BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len); 3514 BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len);
3517 3515
3518 if (L2CAP_CTRL_FINAL & rx_control && 3516 if (L2CAP_CTRL_FINAL & rx_control &&
3519 chan->conn_state & L2CAP_CONN_WAIT_F) { 3517 chan->conn_state & L2CAP_CONN_WAIT_F) {
3520 del_timer(&l2cap_pi(sk)->monitor_timer); 3518 del_timer(&chan->monitor_timer);
3521 if (chan->unacked_frames > 0) 3519 if (chan->unacked_frames > 0)
3522 __mod_retrans_timer(); 3520 __mod_retrans_timer();
3523 chan->conn_state &= ~L2CAP_CONN_WAIT_F; 3521 chan->conn_state &= ~L2CAP_CONN_WAIT_F;
@@ -3572,7 +3570,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3572 len -= 2; 3570 len -= 2;
3573 3571
3574 if (len > pi->mps) { 3572 if (len > pi->mps) {
3575 l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); 3573 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
3576 goto drop; 3574 goto drop;
3577 } 3575 }
3578 3576
@@ -3588,13 +3586,13 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3588 3586
3589 /* check for invalid req-seq */ 3587 /* check for invalid req-seq */
3590 if (req_seq_offset > next_tx_seq_offset) { 3588 if (req_seq_offset > next_tx_seq_offset) {
3591 l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); 3589 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
3592 goto drop; 3590 goto drop;
3593 } 3591 }
3594 3592
3595 if (__is_iframe(control)) { 3593 if (__is_iframe(control)) {
3596 if (len < 0) { 3594 if (len < 0) {
3597 l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); 3595 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
3598 goto drop; 3596 goto drop;
3599 } 3597 }
3600 3598
@@ -3602,7 +3600,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3602 } else { 3600 } else {
3603 if (len != 0) { 3601 if (len != 0) {
3604 BT_ERR("%d", len); 3602 BT_ERR("%d", len);
3605 l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); 3603 l2cap_send_disconn_req(pi->conn, chan, ECONNRESET);
3606 goto drop; 3604 goto drop;
3607 } 3605 }
3608 3606
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f90ca2586eaf..d66886f7eccb 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -866,6 +866,7 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)
866void __l2cap_sock_close(struct sock *sk, int reason) 866void __l2cap_sock_close(struct sock *sk, int reason)
867{ 867{
868 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 868 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
869 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
869 870
870 BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); 871 BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
871 872
@@ -880,9 +881,9 @@ void __l2cap_sock_close(struct sock *sk, int reason)
880 sk->sk_type == SOCK_STREAM) && 881 sk->sk_type == SOCK_STREAM) &&
881 conn->hcon->type == ACL_LINK) { 882 conn->hcon->type == ACL_LINK) {
882 l2cap_sock_set_timer(sk, sk->sk_sndtimeo); 883 l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
883 l2cap_send_disconn_req(conn, sk, reason); 884 l2cap_send_disconn_req(conn, chan, reason);
884 } else 885 } else
885 l2cap_chan_del(l2cap_pi(sk)->chan, reason); 886 l2cap_chan_del(chan, reason);
886 break; 887 break;
887 888
888 case BT_CONNECT2: 889 case BT_CONNECT2:
@@ -901,16 +902,16 @@ void __l2cap_sock_close(struct sock *sk, int reason)
901 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); 902 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
902 rsp.result = cpu_to_le16(result); 903 rsp.result = cpu_to_le16(result);
903 rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); 904 rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
904 l2cap_send_cmd(conn, l2cap_pi(sk)->chan->ident, 905 l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
905 L2CAP_CONN_RSP, sizeof(rsp), &rsp); 906 sizeof(rsp), &rsp);
906 } 907 }
907 908
908 l2cap_chan_del(l2cap_pi(sk)->chan, reason); 909 l2cap_chan_del(chan, reason);
909 break; 910 break;
910 911
911 case BT_CONNECT: 912 case BT_CONNECT:
912 case BT_DISCONN: 913 case BT_DISCONN:
913 l2cap_chan_del(l2cap_pi(sk)->chan, reason); 914 l2cap_chan_del(chan, reason);
914 break; 915 break;
915 916
916 default: 917 default: