aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/l2cap.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index af0fbf9ebfeb..c1b562085cb4 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -366,6 +366,16 @@ static void l2cap_do_start(struct sock *sk)
366 } 366 }
367} 367}
368 368
369static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk)
370{
371 struct l2cap_disconn_req req;
372
373 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
374 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
375 l2cap_send_cmd(conn, l2cap_get_ident(conn),
376 L2CAP_DISCONN_REQ, sizeof(req), &req);
377}
378
369/* ---- L2CAP connections ---- */ 379/* ---- L2CAP connections ---- */
370static void l2cap_conn_start(struct l2cap_conn *conn) 380static void l2cap_conn_start(struct l2cap_conn *conn)
371{ 381{
@@ -650,15 +660,10 @@ static void __l2cap_sock_close(struct sock *sk, int reason)
650 case BT_CONFIG: 660 case BT_CONFIG:
651 if (sk->sk_type == SOCK_SEQPACKET) { 661 if (sk->sk_type == SOCK_SEQPACKET) {
652 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 662 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
653 struct l2cap_disconn_req req;
654 663
655 sk->sk_state = BT_DISCONN; 664 sk->sk_state = BT_DISCONN;
656 l2cap_sock_set_timer(sk, sk->sk_sndtimeo); 665 l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
657 666 l2cap_send_disconn_req(conn, sk);
658 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
659 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
660 l2cap_send_cmd(conn, l2cap_get_ident(conn),
661 L2CAP_DISCONN_REQ, sizeof(req), &req);
662 } else 667 } else
663 l2cap_chan_del(sk, reason); 668 l2cap_chan_del(sk, reason);
664 break; 669 break;
@@ -1786,13 +1791,8 @@ static int l2cap_build_conf_req(struct sock *sk, void *data)
1786 case L2CAP_MODE_STREAMING: 1791 case L2CAP_MODE_STREAMING:
1787 case L2CAP_MODE_ERTM: 1792 case L2CAP_MODE_ERTM:
1788 pi->conf_state |= L2CAP_CONF_STATE2_DEVICE; 1793 pi->conf_state |= L2CAP_CONF_STATE2_DEVICE;
1789 if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask)) { 1794 if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask))
1790 struct l2cap_disconn_req req; 1795 l2cap_send_disconn_req(pi->conn, sk);
1791 req.dcid = cpu_to_le16(pi->dcid);
1792 req.scid = cpu_to_le16(pi->scid);
1793 l2cap_send_cmd(pi->conn, l2cap_get_ident(pi->conn),
1794 L2CAP_DISCONN_REQ, sizeof(req), &req);
1795 }
1796 break; 1796 break;
1797 default: 1797 default:
1798 pi->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask); 1798 pi->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask);
@@ -2286,11 +2286,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2286 /* Complete config. */ 2286 /* Complete config. */
2287 len = l2cap_parse_conf_req(sk, rsp); 2287 len = l2cap_parse_conf_req(sk, rsp);
2288 if (len < 0) { 2288 if (len < 0) {
2289 struct l2cap_disconn_req req; 2289 l2cap_send_disconn_req(conn, sk);
2290 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
2291 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
2292 l2cap_send_cmd(conn, l2cap_get_ident(conn),
2293 L2CAP_DISCONN_REQ, sizeof(req), &req);
2294 goto unlock; 2290 goto unlock;
2295 } 2291 }
2296 2292
@@ -2352,11 +2348,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2352 len = l2cap_parse_conf_rsp(sk, rsp->data, 2348 len = l2cap_parse_conf_rsp(sk, rsp->data,
2353 len, req, &result); 2349 len, req, &result);
2354 if (len < 0) { 2350 if (len < 0) {
2355 struct l2cap_disconn_req req; 2351 l2cap_send_disconn_req(conn, sk);
2356 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
2357 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
2358 l2cap_send_cmd(conn, l2cap_get_ident(conn),
2359 L2CAP_DISCONN_REQ, sizeof(req), &req);
2360 goto done; 2352 goto done;
2361 } 2353 }
2362 2354
@@ -2372,13 +2364,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2372 sk->sk_state = BT_DISCONN; 2364 sk->sk_state = BT_DISCONN;
2373 sk->sk_err = ECONNRESET; 2365 sk->sk_err = ECONNRESET;
2374 l2cap_sock_set_timer(sk, HZ * 5); 2366 l2cap_sock_set_timer(sk, HZ * 5);
2375 { 2367 l2cap_send_disconn_req(conn, sk);
2376 struct l2cap_disconn_req req;
2377 req.dcid = cpu_to_le16(l2cap_pi(sk)->dcid);
2378 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
2379 l2cap_send_cmd(conn, l2cap_get_ident(conn),
2380 L2CAP_DISCONN_REQ, sizeof(req), &req);
2381 }
2382 goto done; 2368 goto done;
2383 } 2369 }
2384 2370