diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-13 16:20:49 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-04-28 00:09:58 -0400 |
commit | 0c1bc5c626e9783034264ccca4b262b3acc628f1 (patch) | |
tree | ca6c9ecaf753ec9892d3cec078c63723299e01fb /net/bluetooth | |
parent | 47d1ec6161da2c7b9dbc56a5200fa26b17d5fdc1 (diff) |
Bluetooth: Move more channel info to struct l2cap_chan
In this commit, omtu, imtu, flush_to, mode and sport. It also remove the
pi var from l2cap_sock_sendmsg().
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/cmtp/core.c | 3 | ||||
-rw-r--r-- | net/bluetooth/hidp/core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 97 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 100 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 11 |
5 files changed, 114 insertions, 103 deletions
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index cce99b0919f5..c5b11af908be 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c | |||
@@ -346,7 +346,8 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock) | |||
346 | 346 | ||
347 | bacpy(&session->bdaddr, &bt_sk(sock->sk)->dst); | 347 | bacpy(&session->bdaddr, &bt_sk(sock->sk)->dst); |
348 | 348 | ||
349 | session->mtu = min_t(uint, l2cap_pi(sock->sk)->omtu, l2cap_pi(sock->sk)->imtu); | 349 | session->mtu = min_t(uint, l2cap_pi(sock->sk)->chan->omtu, |
350 | l2cap_pi(sock->sk)->chan->imtu); | ||
350 | 351 | ||
351 | BT_DBG("mtu %d", session->mtu); | 352 | BT_DBG("mtu %d", session->mtu); |
352 | 353 | ||
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index ae6ebc6c3481..c405a954a603 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -979,8 +979,10 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
979 | 979 | ||
980 | bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst); | 980 | bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst); |
981 | 981 | ||
982 | session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->omtu, l2cap_pi(ctrl_sock->sk)->imtu); | 982 | session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->chan->omtu, |
983 | session->intr_mtu = min_t(uint, l2cap_pi(intr_sock->sk)->omtu, l2cap_pi(intr_sock->sk)->imtu); | 983 | l2cap_pi(ctrl_sock->sk)->chan->imtu); |
984 | session->intr_mtu = min_t(uint, l2cap_pi(intr_sock->sk)->chan->omtu, | ||
985 | l2cap_pi(intr_sock->sk)->chan->imtu); | ||
984 | 986 | ||
985 | BT_DBG("ctrl mtu %d intr mtu %d", session->ctrl_mtu, session->intr_mtu); | 987 | BT_DBG("ctrl mtu %d intr mtu %d", session->ctrl_mtu, session->intr_mtu); |
986 | 988 | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index cb3c4ed47ae2..7b06375d05a7 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -176,24 +176,24 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | |||
176 | if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) { | 176 | if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) { |
177 | if (conn->hcon->type == LE_LINK) { | 177 | if (conn->hcon->type == LE_LINK) { |
178 | /* LE connection */ | 178 | /* LE connection */ |
179 | l2cap_pi(sk)->omtu = L2CAP_LE_DEFAULT_MTU; | 179 | chan->omtu = L2CAP_LE_DEFAULT_MTU; |
180 | l2cap_pi(sk)->scid = L2CAP_CID_LE_DATA; | 180 | l2cap_pi(sk)->scid = L2CAP_CID_LE_DATA; |
181 | l2cap_pi(sk)->dcid = L2CAP_CID_LE_DATA; | 181 | l2cap_pi(sk)->dcid = L2CAP_CID_LE_DATA; |
182 | } else { | 182 | } else { |
183 | /* Alloc CID for connection-oriented socket */ | 183 | /* Alloc CID for connection-oriented socket */ |
184 | l2cap_pi(sk)->scid = l2cap_alloc_cid(conn); | 184 | l2cap_pi(sk)->scid = l2cap_alloc_cid(conn); |
185 | l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU; | 185 | chan->omtu = L2CAP_DEFAULT_MTU; |
186 | } | 186 | } |
187 | } else if (sk->sk_type == SOCK_DGRAM) { | 187 | } else if (sk->sk_type == SOCK_DGRAM) { |
188 | /* Connectionless socket */ | 188 | /* Connectionless socket */ |
189 | l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS; | 189 | l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS; |
190 | l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS; | 190 | l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS; |
191 | l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU; | 191 | chan->omtu = L2CAP_DEFAULT_MTU; |
192 | } else { | 192 | } else { |
193 | /* Raw socket can send/recv signalling messages only */ | 193 | /* Raw socket can send/recv signalling messages only */ |
194 | l2cap_pi(sk)->scid = L2CAP_CID_SIGNALING; | 194 | l2cap_pi(sk)->scid = L2CAP_CID_SIGNALING; |
195 | l2cap_pi(sk)->dcid = L2CAP_CID_SIGNALING; | 195 | l2cap_pi(sk)->dcid = L2CAP_CID_SIGNALING; |
196 | l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU; | 196 | chan->omtu = L2CAP_DEFAULT_MTU; |
197 | } | 197 | } |
198 | 198 | ||
199 | sock_hold(sk); | 199 | sock_hold(sk); |
@@ -242,7 +242,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
242 | 242 | ||
243 | skb_queue_purge(&chan->tx_q); | 243 | skb_queue_purge(&chan->tx_q); |
244 | 244 | ||
245 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { | 245 | if (chan->mode == L2CAP_MODE_ERTM) { |
246 | struct srej_list *l, *tmp; | 246 | struct srej_list *l, *tmp; |
247 | 247 | ||
248 | del_timer(&chan->retrans_timer); | 248 | del_timer(&chan->retrans_timer); |
@@ -479,7 +479,7 @@ void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, in | |||
479 | 479 | ||
480 | sk = chan->sk; | 480 | sk = chan->sk; |
481 | 481 | ||
482 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) { | 482 | if (chan->mode == L2CAP_MODE_ERTM) { |
483 | del_timer(&chan->retrans_timer); | 483 | del_timer(&chan->retrans_timer); |
484 | del_timer(&chan->monitor_timer); | 484 | del_timer(&chan->monitor_timer); |
485 | del_timer(&chan->ack_timer); | 485 | del_timer(&chan->ack_timer); |
@@ -523,7 +523,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
523 | continue; | 523 | continue; |
524 | } | 524 | } |
525 | 525 | ||
526 | if (!l2cap_mode_supported(l2cap_pi(sk)->mode, | 526 | if (!l2cap_mode_supported(chan->mode, |
527 | conn->feat_mask) | 527 | conn->feat_mask) |
528 | && chan->conf_state & | 528 | && chan->conf_state & |
529 | L2CAP_CONF_STATE2_DEVICE) { | 529 | L2CAP_CONF_STATE2_DEVICE) { |
@@ -1609,7 +1609,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) | |||
1609 | { | 1609 | { |
1610 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | 1610 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); |
1611 | struct l2cap_conf_req *req = data; | 1611 | struct l2cap_conf_req *req = data; |
1612 | struct l2cap_conf_rfc rfc = { .mode = pi->mode }; | 1612 | struct l2cap_conf_rfc rfc = { .mode = chan->mode }; |
1613 | void *ptr = req->data; | 1613 | void *ptr = req->data; |
1614 | 1614 | ||
1615 | BT_DBG("chan %p", chan); | 1615 | BT_DBG("chan %p", chan); |
@@ -1617,7 +1617,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) | |||
1617 | if (chan->num_conf_req || chan->num_conf_rsp) | 1617 | if (chan->num_conf_req || chan->num_conf_rsp) |
1618 | goto done; | 1618 | goto done; |
1619 | 1619 | ||
1620 | switch (pi->mode) { | 1620 | switch (chan->mode) { |
1621 | case L2CAP_MODE_STREAMING: | 1621 | case L2CAP_MODE_STREAMING: |
1622 | case L2CAP_MODE_ERTM: | 1622 | case L2CAP_MODE_ERTM: |
1623 | if (chan->conf_state & L2CAP_CONF_STATE2_DEVICE) | 1623 | if (chan->conf_state & L2CAP_CONF_STATE2_DEVICE) |
@@ -1625,15 +1625,15 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) | |||
1625 | 1625 | ||
1626 | /* fall through */ | 1626 | /* fall through */ |
1627 | default: | 1627 | default: |
1628 | pi->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask); | 1628 | chan->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask); |
1629 | break; | 1629 | break; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | done: | 1632 | done: |
1633 | if (pi->imtu != L2CAP_DEFAULT_MTU) | 1633 | if (chan->imtu != L2CAP_DEFAULT_MTU) |
1634 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu); | 1634 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu); |
1635 | 1635 | ||
1636 | switch (pi->mode) { | 1636 | switch (chan->mode) { |
1637 | case L2CAP_MODE_BASIC: | 1637 | case L2CAP_MODE_BASIC: |
1638 | if (!(pi->conn->feat_mask & L2CAP_FEAT_ERTM) && | 1638 | if (!(pi->conn->feat_mask & L2CAP_FEAT_ERTM) && |
1639 | !(pi->conn->feat_mask & L2CAP_FEAT_STREAMING)) | 1639 | !(pi->conn->feat_mask & L2CAP_FEAT_STREAMING)) |
@@ -1730,7 +1730,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
1730 | break; | 1730 | break; |
1731 | 1731 | ||
1732 | case L2CAP_CONF_FLUSH_TO: | 1732 | case L2CAP_CONF_FLUSH_TO: |
1733 | pi->flush_to = val; | 1733 | chan->flush_to = val; |
1734 | break; | 1734 | break; |
1735 | 1735 | ||
1736 | case L2CAP_CONF_QOS: | 1736 | case L2CAP_CONF_QOS: |
@@ -1760,25 +1760,25 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
1760 | if (chan->num_conf_rsp || chan->num_conf_req > 1) | 1760 | if (chan->num_conf_rsp || chan->num_conf_req > 1) |
1761 | goto done; | 1761 | goto done; |
1762 | 1762 | ||
1763 | switch (pi->mode) { | 1763 | switch (chan->mode) { |
1764 | case L2CAP_MODE_STREAMING: | 1764 | case L2CAP_MODE_STREAMING: |
1765 | case L2CAP_MODE_ERTM: | 1765 | case L2CAP_MODE_ERTM: |
1766 | if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { | 1766 | if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { |
1767 | pi->mode = l2cap_select_mode(rfc.mode, | 1767 | chan->mode = l2cap_select_mode(rfc.mode, |
1768 | pi->conn->feat_mask); | 1768 | pi->conn->feat_mask); |
1769 | break; | 1769 | break; |
1770 | } | 1770 | } |
1771 | 1771 | ||
1772 | if (pi->mode != rfc.mode) | 1772 | if (chan->mode != rfc.mode) |
1773 | return -ECONNREFUSED; | 1773 | return -ECONNREFUSED; |
1774 | 1774 | ||
1775 | break; | 1775 | break; |
1776 | } | 1776 | } |
1777 | 1777 | ||
1778 | done: | 1778 | done: |
1779 | if (pi->mode != rfc.mode) { | 1779 | if (chan->mode != rfc.mode) { |
1780 | result = L2CAP_CONF_UNACCEPT; | 1780 | result = L2CAP_CONF_UNACCEPT; |
1781 | rfc.mode = pi->mode; | 1781 | rfc.mode = chan->mode; |
1782 | 1782 | ||
1783 | if (chan->num_conf_rsp == 1) | 1783 | if (chan->num_conf_rsp == 1) |
1784 | return -ECONNREFUSED; | 1784 | return -ECONNREFUSED; |
@@ -1795,10 +1795,10 @@ done: | |||
1795 | if (mtu < L2CAP_DEFAULT_MIN_MTU) | 1795 | if (mtu < L2CAP_DEFAULT_MIN_MTU) |
1796 | result = L2CAP_CONF_UNACCEPT; | 1796 | result = L2CAP_CONF_UNACCEPT; |
1797 | else { | 1797 | else { |
1798 | pi->omtu = mtu; | 1798 | chan->omtu = mtu; |
1799 | chan->conf_state |= L2CAP_CONF_MTU_DONE; | 1799 | chan->conf_state |= L2CAP_CONF_MTU_DONE; |
1800 | } | 1800 | } |
1801 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu); | 1801 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); |
1802 | 1802 | ||
1803 | switch (rfc.mode) { | 1803 | switch (rfc.mode) { |
1804 | case L2CAP_MODE_BASIC: | 1804 | case L2CAP_MODE_BASIC: |
@@ -1844,7 +1844,7 @@ done: | |||
1844 | result = L2CAP_CONF_UNACCEPT; | 1844 | result = L2CAP_CONF_UNACCEPT; |
1845 | 1845 | ||
1846 | memset(&rfc, 0, sizeof(rfc)); | 1846 | memset(&rfc, 0, sizeof(rfc)); |
1847 | rfc.mode = pi->mode; | 1847 | rfc.mode = chan->mode; |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | if (result == L2CAP_CONF_SUCCESS) | 1850 | if (result == L2CAP_CONF_SUCCESS) |
@@ -1876,16 +1876,16 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
1876 | case L2CAP_CONF_MTU: | 1876 | case L2CAP_CONF_MTU: |
1877 | if (val < L2CAP_DEFAULT_MIN_MTU) { | 1877 | if (val < L2CAP_DEFAULT_MIN_MTU) { |
1878 | *result = L2CAP_CONF_UNACCEPT; | 1878 | *result = L2CAP_CONF_UNACCEPT; |
1879 | pi->imtu = L2CAP_DEFAULT_MIN_MTU; | 1879 | chan->imtu = L2CAP_DEFAULT_MIN_MTU; |
1880 | } else | 1880 | } else |
1881 | pi->imtu = val; | 1881 | chan->imtu = val; |
1882 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu); | 1882 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->imtu); |
1883 | break; | 1883 | break; |
1884 | 1884 | ||
1885 | case L2CAP_CONF_FLUSH_TO: | 1885 | case L2CAP_CONF_FLUSH_TO: |
1886 | pi->flush_to = val; | 1886 | chan->flush_to = val; |
1887 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, | 1887 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, |
1888 | 2, pi->flush_to); | 1888 | 2, chan->flush_to); |
1889 | break; | 1889 | break; |
1890 | 1890 | ||
1891 | case L2CAP_CONF_RFC: | 1891 | case L2CAP_CONF_RFC: |
@@ -1893,7 +1893,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
1893 | memcpy(&rfc, (void *)val, olen); | 1893 | memcpy(&rfc, (void *)val, olen); |
1894 | 1894 | ||
1895 | if ((chan->conf_state & L2CAP_CONF_STATE2_DEVICE) && | 1895 | if ((chan->conf_state & L2CAP_CONF_STATE2_DEVICE) && |
1896 | rfc.mode != pi->mode) | 1896 | rfc.mode != chan->mode) |
1897 | return -ECONNREFUSED; | 1897 | return -ECONNREFUSED; |
1898 | 1898 | ||
1899 | chan->fcs = 0; | 1899 | chan->fcs = 0; |
@@ -1904,10 +1904,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
1904 | } | 1904 | } |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | if (pi->mode == L2CAP_MODE_BASIC && pi->mode != rfc.mode) | 1907 | if (chan->mode == L2CAP_MODE_BASIC && chan->mode != rfc.mode) |
1908 | return -ECONNREFUSED; | 1908 | return -ECONNREFUSED; |
1909 | 1909 | ||
1910 | pi->mode = rfc.mode; | 1910 | chan->mode = rfc.mode; |
1911 | 1911 | ||
1912 | if (*result == L2CAP_CONF_SUCCESS) { | 1912 | if (*result == L2CAP_CONF_SUCCESS) { |
1913 | switch (rfc.mode) { | 1913 | switch (rfc.mode) { |
@@ -1968,14 +1968,13 @@ void __l2cap_connect_rsp_defer(struct sock *sk) | |||
1968 | 1968 | ||
1969 | static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) | 1969 | static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) |
1970 | { | 1970 | { |
1971 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | ||
1972 | int type, olen; | 1971 | int type, olen; |
1973 | unsigned long val; | 1972 | unsigned long val; |
1974 | struct l2cap_conf_rfc rfc; | 1973 | struct l2cap_conf_rfc rfc; |
1975 | 1974 | ||
1976 | BT_DBG("chan %p, rsp %p, len %d", chan, rsp, len); | 1975 | BT_DBG("chan %p, rsp %p, len %d", chan, rsp, len); |
1977 | 1976 | ||
1978 | if ((pi->mode != L2CAP_MODE_ERTM) && (pi->mode != L2CAP_MODE_STREAMING)) | 1977 | if ((chan->mode != L2CAP_MODE_ERTM) && (chan->mode != L2CAP_MODE_STREAMING)) |
1979 | return; | 1978 | return; |
1980 | 1979 | ||
1981 | while (len >= L2CAP_CONF_OPT_SIZE) { | 1980 | while (len >= L2CAP_CONF_OPT_SIZE) { |
@@ -2232,7 +2231,7 @@ static inline void set_default_fcs(struct l2cap_chan *chan) | |||
2232 | /* FCS is enabled only in ERTM or streaming mode, if one or both | 2231 | /* FCS is enabled only in ERTM or streaming mode, if one or both |
2233 | * sides request it. | 2232 | * sides request it. |
2234 | */ | 2233 | */ |
2235 | if (pi->mode != L2CAP_MODE_ERTM && pi->mode != L2CAP_MODE_STREAMING) | 2234 | if (chan->mode != L2CAP_MODE_ERTM && chan->mode != L2CAP_MODE_STREAMING) |
2236 | chan->fcs = L2CAP_FCS_NONE; | 2235 | chan->fcs = L2CAP_FCS_NONE; |
2237 | else if (!(pi->chan->conf_state & L2CAP_CONF_NO_FCS_RECV)) | 2236 | else if (!(pi->chan->conf_state & L2CAP_CONF_NO_FCS_RECV)) |
2238 | chan->fcs = L2CAP_FCS_CRC16; | 2237 | chan->fcs = L2CAP_FCS_CRC16; |
@@ -2312,7 +2311,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2312 | chan->next_tx_seq = 0; | 2311 | chan->next_tx_seq = 0; |
2313 | chan->expected_tx_seq = 0; | 2312 | chan->expected_tx_seq = 0; |
2314 | skb_queue_head_init(&chan->tx_q); | 2313 | skb_queue_head_init(&chan->tx_q); |
2315 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | 2314 | if (chan->mode == L2CAP_MODE_ERTM) |
2316 | l2cap_ertm_init(chan); | 2315 | l2cap_ertm_init(chan); |
2317 | 2316 | ||
2318 | l2cap_chan_ready(sk); | 2317 | l2cap_chan_ready(sk); |
@@ -2403,7 +2402,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2403 | chan->next_tx_seq = 0; | 2402 | chan->next_tx_seq = 0; |
2404 | chan->expected_tx_seq = 0; | 2403 | chan->expected_tx_seq = 0; |
2405 | skb_queue_head_init(&chan->tx_q); | 2404 | skb_queue_head_init(&chan->tx_q); |
2406 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | 2405 | if (chan->mode == L2CAP_MODE_ERTM) |
2407 | l2cap_ertm_init(chan); | 2406 | l2cap_ertm_init(chan); |
2408 | 2407 | ||
2409 | l2cap_chan_ready(sk); | 2408 | l2cap_chan_ready(sk); |
@@ -2876,7 +2875,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2876 | 2875 | ||
2877 | chan->sdu_len = get_unaligned_le16(skb->data); | 2876 | chan->sdu_len = get_unaligned_le16(skb->data); |
2878 | 2877 | ||
2879 | if (chan->sdu_len > pi->imtu) | 2878 | if (chan->sdu_len > chan->imtu) |
2880 | goto disconnect; | 2879 | goto disconnect; |
2881 | 2880 | ||
2882 | chan->sdu = bt_skb_alloc(chan->sdu_len, GFP_ATOMIC); | 2881 | chan->sdu = bt_skb_alloc(chan->sdu_len, GFP_ATOMIC); |
@@ -2919,7 +2918,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
2919 | if (!(chan->conn_state & L2CAP_CONN_SAR_RETRY)) { | 2918 | if (!(chan->conn_state & L2CAP_CONN_SAR_RETRY)) { |
2920 | chan->partial_sdu_len += skb->len; | 2919 | chan->partial_sdu_len += skb->len; |
2921 | 2920 | ||
2922 | if (chan->partial_sdu_len > pi->imtu) | 2921 | if (chan->partial_sdu_len > chan->imtu) |
2923 | goto drop; | 2922 | goto drop; |
2924 | 2923 | ||
2925 | if (chan->partial_sdu_len != chan->sdu_len) | 2924 | if (chan->partial_sdu_len != chan->sdu_len) |
@@ -3087,7 +3086,6 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c | |||
3087 | 3086 | ||
3088 | static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) | 3087 | static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) |
3089 | { | 3088 | { |
3090 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | ||
3091 | struct sk_buff *_skb; | 3089 | struct sk_buff *_skb; |
3092 | int err = -EINVAL; | 3090 | int err = -EINVAL; |
3093 | 3091 | ||
@@ -3118,7 +3116,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3118 | chan->sdu_len = get_unaligned_le16(skb->data); | 3116 | chan->sdu_len = get_unaligned_le16(skb->data); |
3119 | skb_pull(skb, 2); | 3117 | skb_pull(skb, 2); |
3120 | 3118 | ||
3121 | if (chan->sdu_len > pi->imtu) { | 3119 | if (chan->sdu_len > chan->imtu) { |
3122 | err = -EMSGSIZE; | 3120 | err = -EMSGSIZE; |
3123 | break; | 3121 | break; |
3124 | } | 3122 | } |
@@ -3159,7 +3157,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3159 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; | 3157 | chan->conn_state &= ~L2CAP_CONN_SAR_SDU; |
3160 | chan->partial_sdu_len += skb->len; | 3158 | chan->partial_sdu_len += skb->len; |
3161 | 3159 | ||
3162 | if (chan->partial_sdu_len > pi->imtu) | 3160 | if (chan->partial_sdu_len > chan->imtu) |
3163 | goto drop; | 3161 | goto drop; |
3164 | 3162 | ||
3165 | if (chan->partial_sdu_len == chan->sdu_len) { | 3163 | if (chan->partial_sdu_len == chan->sdu_len) { |
@@ -3625,14 +3623,14 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
3625 | if (sk->sk_state != BT_CONNECTED) | 3623 | if (sk->sk_state != BT_CONNECTED) |
3626 | goto drop; | 3624 | goto drop; |
3627 | 3625 | ||
3628 | switch (pi->mode) { | 3626 | switch (chan->mode) { |
3629 | case L2CAP_MODE_BASIC: | 3627 | case L2CAP_MODE_BASIC: |
3630 | /* If socket recv buffers overflows we drop data here | 3628 | /* If socket recv buffers overflows we drop data here |
3631 | * which is *bad* because L2CAP has to be reliable. | 3629 | * which is *bad* because L2CAP has to be reliable. |
3632 | * But we don't have any other choice. L2CAP doesn't | 3630 | * But we don't have any other choice. L2CAP doesn't |
3633 | * provide flow control mechanism. */ | 3631 | * provide flow control mechanism. */ |
3634 | 3632 | ||
3635 | if (pi->imtu < skb->len) | 3633 | if (chan->imtu < skb->len) |
3636 | goto drop; | 3634 | goto drop; |
3637 | 3635 | ||
3638 | if (!sock_queue_rcv_skb(sk, skb)) | 3636 | if (!sock_queue_rcv_skb(sk, skb)) |
@@ -3678,7 +3676,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
3678 | goto done; | 3676 | goto done; |
3679 | 3677 | ||
3680 | default: | 3678 | default: |
3681 | BT_DBG("chan %p: bad mode 0x%2.2x", chan, pi->mode); | 3679 | BT_DBG("chan %p: bad mode 0x%2.2x", chan, chan->mode); |
3682 | break; | 3680 | break; |
3683 | } | 3681 | } |
3684 | 3682 | ||
@@ -3707,7 +3705,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str | |||
3707 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) | 3705 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) |
3708 | goto drop; | 3706 | goto drop; |
3709 | 3707 | ||
3710 | if (l2cap_pi(sk)->imtu < skb->len) | 3708 | if (l2cap_pi(sk)->chan->imtu < skb->len) |
3711 | goto drop; | 3709 | goto drop; |
3712 | 3710 | ||
3713 | if (!sock_queue_rcv_skb(sk, skb)) | 3711 | if (!sock_queue_rcv_skb(sk, skb)) |
@@ -3737,7 +3735,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct | |||
3737 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) | 3735 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) |
3738 | goto drop; | 3736 | goto drop; |
3739 | 3737 | ||
3740 | if (l2cap_pi(sk)->imtu < skb->len) | 3738 | if (l2cap_pi(sk)->chan->imtu < skb->len) |
3741 | goto drop; | 3739 | goto drop; |
3742 | 3740 | ||
3743 | if (!sock_queue_rcv_skb(sk, skb)) | 3741 | if (!sock_queue_rcv_skb(sk, skb)) |
@@ -4020,10 +4018,10 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl | |||
4020 | if (chan && chan->sk) { | 4018 | if (chan && chan->sk) { |
4021 | struct sock *sk = chan->sk; | 4019 | struct sock *sk = chan->sk; |
4022 | 4020 | ||
4023 | if (l2cap_pi(sk)->imtu < len - L2CAP_HDR_SIZE) { | 4021 | if (chan->imtu < len - L2CAP_HDR_SIZE) { |
4024 | BT_ERR("Frame exceeding recv MTU (len %d, " | 4022 | BT_ERR("Frame exceeding recv MTU (len %d, " |
4025 | "MTU %d)", len, | 4023 | "MTU %d)", len, |
4026 | l2cap_pi(sk)->imtu); | 4024 | chan->imtu); |
4027 | bh_unlock_sock(sk); | 4025 | bh_unlock_sock(sk); |
4028 | l2cap_conn_unreliable(conn, ECOMM); | 4026 | l2cap_conn_unreliable(conn, ECOMM); |
4029 | goto drop; | 4027 | goto drop; |
@@ -4083,14 +4081,15 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p) | |||
4083 | 4081 | ||
4084 | sk_for_each(sk, node, &l2cap_sk_list.head) { | 4082 | sk_for_each(sk, node, &l2cap_sk_list.head) { |
4085 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 4083 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
4084 | struct l2cap_chan *chan = pi->chan; | ||
4086 | 4085 | ||
4087 | seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n", | 4086 | seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n", |
4088 | batostr(&bt_sk(sk)->src), | 4087 | batostr(&bt_sk(sk)->src), |
4089 | batostr(&bt_sk(sk)->dst), | 4088 | batostr(&bt_sk(sk)->dst), |
4090 | sk->sk_state, __le16_to_cpu(pi->psm), | 4089 | sk->sk_state, __le16_to_cpu(pi->psm), |
4091 | pi->scid, pi->dcid, | 4090 | pi->scid, pi->dcid, |
4092 | pi->imtu, pi->omtu, pi->chan->sec_level, | 4091 | chan->imtu, chan->omtu, chan->sec_level, |
4093 | pi->mode); | 4092 | chan->mode); |
4094 | } | 4093 | } |
4095 | 4094 | ||
4096 | read_unlock_bh(&l2cap_sk_list.lock); | 4095 | read_unlock_bh(&l2cap_sk_list.lock); |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 4ba15b3b2e6a..eef33b179f02 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -80,9 +80,13 @@ static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src) | |||
80 | { | 80 | { |
81 | struct sock *sk; | 81 | struct sock *sk; |
82 | struct hlist_node *node; | 82 | struct hlist_node *node; |
83 | sk_for_each(sk, node, &l2cap_sk_list.head) | 83 | sk_for_each(sk, node, &l2cap_sk_list.head) { |
84 | if (l2cap_pi(sk)->sport == psm && !bacmp(&bt_sk(sk)->src, src)) | 84 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
85 | |||
86 | if (chan->sport == psm && !bacmp(&bt_sk(sk)->src, src)) | ||
85 | goto found; | 87 | goto found; |
88 | } | ||
89 | |||
86 | sk = NULL; | 90 | sk = NULL; |
87 | found: | 91 | found: |
88 | return sk; | 92 | return sk; |
@@ -138,7 +142,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) | |||
138 | /* Save source address */ | 142 | /* Save source address */ |
139 | bacpy(&bt_sk(sk)->src, &la.l2_bdaddr); | 143 | bacpy(&bt_sk(sk)->src, &la.l2_bdaddr); |
140 | l2cap_pi(sk)->psm = la.l2_psm; | 144 | l2cap_pi(sk)->psm = la.l2_psm; |
141 | l2cap_pi(sk)->sport = la.l2_psm; | 145 | chan->sport = la.l2_psm; |
142 | sk->sk_state = BT_BOUND; | 146 | sk->sk_state = BT_BOUND; |
143 | 147 | ||
144 | if (__le16_to_cpu(la.l2_psm) == 0x0001 || | 148 | if (__le16_to_cpu(la.l2_psm) == 0x0001 || |
@@ -159,6 +163,7 @@ done: | |||
159 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) | 163 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) |
160 | { | 164 | { |
161 | struct sock *sk = sock->sk; | 165 | struct sock *sk = sock->sk; |
166 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
162 | struct sockaddr_l2 la; | 167 | struct sockaddr_l2 la; |
163 | int len, err = 0; | 168 | int len, err = 0; |
164 | 169 | ||
@@ -183,7 +188,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
183 | goto done; | 188 | goto done; |
184 | } | 189 | } |
185 | 190 | ||
186 | switch (l2cap_pi(sk)->mode) { | 191 | switch (chan->mode) { |
187 | case L2CAP_MODE_BASIC: | 192 | case L2CAP_MODE_BASIC: |
188 | break; | 193 | break; |
189 | case L2CAP_MODE_ERTM: | 194 | case L2CAP_MODE_ERTM: |
@@ -245,6 +250,7 @@ done: | |||
245 | static int l2cap_sock_listen(struct socket *sock, int backlog) | 250 | static int l2cap_sock_listen(struct socket *sock, int backlog) |
246 | { | 251 | { |
247 | struct sock *sk = sock->sk; | 252 | struct sock *sk = sock->sk; |
253 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
248 | int err = 0; | 254 | int err = 0; |
249 | 255 | ||
250 | BT_DBG("sk %p backlog %d", sk, backlog); | 256 | BT_DBG("sk %p backlog %d", sk, backlog); |
@@ -257,7 +263,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) | |||
257 | goto done; | 263 | goto done; |
258 | } | 264 | } |
259 | 265 | ||
260 | switch (l2cap_pi(sk)->mode) { | 266 | switch (chan->mode) { |
261 | case L2CAP_MODE_BASIC: | 267 | case L2CAP_MODE_BASIC: |
262 | break; | 268 | break; |
263 | case L2CAP_MODE_ERTM: | 269 | case L2CAP_MODE_ERTM: |
@@ -281,7 +287,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) | |||
281 | for (psm = 0x1001; psm < 0x1100; psm += 2) | 287 | for (psm = 0x1001; psm < 0x1100; psm += 2) |
282 | if (!__l2cap_get_sock_by_addr(cpu_to_le16(psm), src)) { | 288 | if (!__l2cap_get_sock_by_addr(cpu_to_le16(psm), src)) { |
283 | l2cap_pi(sk)->psm = cpu_to_le16(psm); | 289 | l2cap_pi(sk)->psm = cpu_to_le16(psm); |
284 | l2cap_pi(sk)->sport = cpu_to_le16(psm); | 290 | chan->sport = cpu_to_le16(psm); |
285 | err = 0; | 291 | err = 0; |
286 | break; | 292 | break; |
287 | } | 293 | } |
@@ -361,6 +367,7 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l | |||
361 | { | 367 | { |
362 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; | 368 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; |
363 | struct sock *sk = sock->sk; | 369 | struct sock *sk = sock->sk; |
370 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
364 | 371 | ||
365 | BT_DBG("sock %p, sk %p", sock, sk); | 372 | BT_DBG("sock %p, sk %p", sock, sk); |
366 | 373 | ||
@@ -372,7 +379,7 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l | |||
372 | bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst); | 379 | bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst); |
373 | la->l2_cid = cpu_to_le16(l2cap_pi(sk)->dcid); | 380 | la->l2_cid = cpu_to_le16(l2cap_pi(sk)->dcid); |
374 | } else { | 381 | } else { |
375 | la->l2_psm = l2cap_pi(sk)->sport; | 382 | la->l2_psm = chan->sport; |
376 | bacpy(&la->l2_bdaddr, &bt_sk(sk)->src); | 383 | bacpy(&la->l2_bdaddr, &bt_sk(sk)->src); |
377 | la->l2_cid = cpu_to_le16(l2cap_pi(sk)->scid); | 384 | la->l2_cid = cpu_to_le16(l2cap_pi(sk)->scid); |
378 | } | 385 | } |
@@ -399,10 +406,10 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us | |||
399 | switch (optname) { | 406 | switch (optname) { |
400 | case L2CAP_OPTIONS: | 407 | case L2CAP_OPTIONS: |
401 | memset(&opts, 0, sizeof(opts)); | 408 | memset(&opts, 0, sizeof(opts)); |
402 | opts.imtu = l2cap_pi(sk)->imtu; | 409 | opts.imtu = chan->imtu; |
403 | opts.omtu = l2cap_pi(sk)->omtu; | 410 | opts.omtu = chan->omtu; |
404 | opts.flush_to = l2cap_pi(sk)->flush_to; | 411 | opts.flush_to = chan->flush_to; |
405 | opts.mode = l2cap_pi(sk)->mode; | 412 | opts.mode = chan->mode; |
406 | opts.fcs = chan->fcs; | 413 | opts.fcs = chan->fcs; |
407 | opts.max_tx = chan->max_tx; | 414 | opts.max_tx = chan->max_tx; |
408 | opts.txwin_size = (__u16)chan->tx_win; | 415 | opts.txwin_size = (__u16)chan->tx_win; |
@@ -547,10 +554,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
547 | break; | 554 | break; |
548 | } | 555 | } |
549 | 556 | ||
550 | opts.imtu = l2cap_pi(sk)->imtu; | 557 | opts.imtu = chan->imtu; |
551 | opts.omtu = l2cap_pi(sk)->omtu; | 558 | opts.omtu = chan->omtu; |
552 | opts.flush_to = l2cap_pi(sk)->flush_to; | 559 | opts.flush_to = chan->flush_to; |
553 | opts.mode = l2cap_pi(sk)->mode; | 560 | opts.mode = chan->mode; |
554 | opts.fcs = chan->fcs; | 561 | opts.fcs = chan->fcs; |
555 | opts.max_tx = chan->max_tx; | 562 | opts.max_tx = chan->max_tx; |
556 | opts.txwin_size = (__u16)chan->tx_win; | 563 | opts.txwin_size = (__u16)chan->tx_win; |
@@ -566,8 +573,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
566 | break; | 573 | break; |
567 | } | 574 | } |
568 | 575 | ||
569 | l2cap_pi(sk)->mode = opts.mode; | 576 | chan->mode = opts.mode; |
570 | switch (l2cap_pi(sk)->mode) { | 577 | switch (chan->mode) { |
571 | case L2CAP_MODE_BASIC: | 578 | case L2CAP_MODE_BASIC: |
572 | chan->conf_state &= ~L2CAP_CONF_STATE2_DEVICE; | 579 | chan->conf_state &= ~L2CAP_CONF_STATE2_DEVICE; |
573 | break; | 580 | break; |
@@ -581,8 +588,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
581 | break; | 588 | break; |
582 | } | 589 | } |
583 | 590 | ||
584 | l2cap_pi(sk)->imtu = opts.imtu; | 591 | chan->imtu = opts.imtu; |
585 | l2cap_pi(sk)->omtu = opts.omtu; | 592 | chan->omtu = opts.omtu; |
586 | chan->fcs = opts.fcs; | 593 | chan->fcs = opts.fcs; |
587 | chan->max_tx = opts.max_tx; | 594 | chan->max_tx = opts.max_tx; |
588 | chan->tx_win = (__u8)opts.txwin_size; | 595 | chan->tx_win = (__u8)opts.txwin_size; |
@@ -707,7 +714,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
707 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) | 714 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) |
708 | { | 715 | { |
709 | struct sock *sk = sock->sk; | 716 | struct sock *sk = sock->sk; |
710 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 717 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
711 | struct sk_buff *skb; | 718 | struct sk_buff *skb; |
712 | u16 control; | 719 | u16 control; |
713 | int err; | 720 | int err; |
@@ -734,16 +741,16 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
734 | if (IS_ERR(skb)) { | 741 | if (IS_ERR(skb)) { |
735 | err = PTR_ERR(skb); | 742 | err = PTR_ERR(skb); |
736 | } else { | 743 | } else { |
737 | l2cap_do_send(pi->chan, skb); | 744 | l2cap_do_send(chan, skb); |
738 | err = len; | 745 | err = len; |
739 | } | 746 | } |
740 | goto done; | 747 | goto done; |
741 | } | 748 | } |
742 | 749 | ||
743 | switch (pi->mode) { | 750 | switch (chan->mode) { |
744 | case L2CAP_MODE_BASIC: | 751 | case L2CAP_MODE_BASIC: |
745 | /* Check outgoing MTU */ | 752 | /* Check outgoing MTU */ |
746 | if (len > pi->omtu) { | 753 | if (len > chan->omtu) { |
747 | err = -EMSGSIZE; | 754 | err = -EMSGSIZE; |
748 | goto done; | 755 | goto done; |
749 | } | 756 | } |
@@ -755,52 +762,52 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
755 | goto done; | 762 | goto done; |
756 | } | 763 | } |
757 | 764 | ||
758 | l2cap_do_send(pi->chan, skb); | 765 | l2cap_do_send(chan, skb); |
759 | err = len; | 766 | err = len; |
760 | break; | 767 | break; |
761 | 768 | ||
762 | case L2CAP_MODE_ERTM: | 769 | case L2CAP_MODE_ERTM: |
763 | case L2CAP_MODE_STREAMING: | 770 | case L2CAP_MODE_STREAMING: |
764 | /* Entire SDU fits into one PDU */ | 771 | /* Entire SDU fits into one PDU */ |
765 | if (len <= pi->chan->remote_mps) { | 772 | if (len <= chan->remote_mps) { |
766 | control = L2CAP_SDU_UNSEGMENTED; | 773 | control = L2CAP_SDU_UNSEGMENTED; |
767 | skb = l2cap_create_iframe_pdu(pi->chan, msg, len, | 774 | skb = l2cap_create_iframe_pdu(chan, msg, len, control, |
768 | control, 0); | 775 | 0); |
769 | if (IS_ERR(skb)) { | 776 | if (IS_ERR(skb)) { |
770 | err = PTR_ERR(skb); | 777 | err = PTR_ERR(skb); |
771 | goto done; | 778 | goto done; |
772 | } | 779 | } |
773 | __skb_queue_tail(&pi->chan->tx_q, skb); | 780 | __skb_queue_tail(&chan->tx_q, skb); |
774 | 781 | ||
775 | if (pi->chan->tx_send_head == NULL) | 782 | if (chan->tx_send_head == NULL) |
776 | pi->chan->tx_send_head = skb; | 783 | chan->tx_send_head = skb; |
777 | 784 | ||
778 | } else { | 785 | } else { |
779 | /* Segment SDU into multiples PDUs */ | 786 | /* Segment SDU into multiples PDUs */ |
780 | err = l2cap_sar_segment_sdu(pi->chan, msg, len); | 787 | err = l2cap_sar_segment_sdu(chan, msg, len); |
781 | if (err < 0) | 788 | if (err < 0) |
782 | goto done; | 789 | goto done; |
783 | } | 790 | } |
784 | 791 | ||
785 | if (pi->mode == L2CAP_MODE_STREAMING) { | 792 | if (chan->mode == L2CAP_MODE_STREAMING) { |
786 | l2cap_streaming_send(pi->chan); | 793 | l2cap_streaming_send(chan); |
787 | err = len; | 794 | err = len; |
788 | break; | 795 | break; |
789 | } | 796 | } |
790 | 797 | ||
791 | if ((pi->chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && | 798 | if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && |
792 | (pi->chan->conn_state & L2CAP_CONN_WAIT_F)) { | 799 | (chan->conn_state & L2CAP_CONN_WAIT_F)) { |
793 | err = len; | 800 | err = len; |
794 | break; | 801 | break; |
795 | } | 802 | } |
796 | err = l2cap_ertm_send(pi->chan); | 803 | err = l2cap_ertm_send(chan); |
797 | 804 | ||
798 | if (err >= 0) | 805 | if (err >= 0) |
799 | err = len; | 806 | err = len; |
800 | break; | 807 | break; |
801 | 808 | ||
802 | default: | 809 | default: |
803 | BT_DBG("bad state %1.1x", pi->mode); | 810 | BT_DBG("bad state %1.1x", chan->mode); |
804 | err = -EBADFD; | 811 | err = -EBADFD; |
805 | } | 812 | } |
806 | 813 | ||
@@ -929,6 +936,7 @@ void __l2cap_sock_close(struct sock *sk, int reason) | |||
929 | static int l2cap_sock_shutdown(struct socket *sock, int how) | 936 | static int l2cap_sock_shutdown(struct socket *sock, int how) |
930 | { | 937 | { |
931 | struct sock *sk = sock->sk; | 938 | struct sock *sk = sock->sk; |
939 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
932 | int err = 0; | 940 | int err = 0; |
933 | 941 | ||
934 | BT_DBG("sock %p, sk %p", sock, sk); | 942 | BT_DBG("sock %p, sk %p", sock, sk); |
@@ -938,7 +946,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) | |||
938 | 946 | ||
939 | lock_sock(sk); | 947 | lock_sock(sk); |
940 | if (!sk->sk_shutdown) { | 948 | if (!sk->sk_shutdown) { |
941 | if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) | 949 | if (chan->mode == L2CAP_MODE_ERTM) |
942 | err = __l2cap_wait_ack(sk); | 950 | err = __l2cap_wait_ack(sk); |
943 | 951 | ||
944 | sk->sk_shutdown = SHUTDOWN_MASK; | 952 | sk->sk_shutdown = SHUTDOWN_MASK; |
@@ -995,10 +1003,10 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
995 | sk->sk_type = parent->sk_type; | 1003 | sk->sk_type = parent->sk_type; |
996 | bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; | 1004 | bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; |
997 | 1005 | ||
998 | pi->imtu = l2cap_pi(parent)->imtu; | 1006 | chan->imtu = pchan->imtu; |
999 | pi->omtu = l2cap_pi(parent)->omtu; | 1007 | chan->omtu = pchan->omtu; |
1000 | chan->conf_state = pchan->conf_state; | 1008 | chan->conf_state = pchan->conf_state; |
1001 | pi->mode = l2cap_pi(parent)->mode; | 1009 | chan->mode = pchan->mode; |
1002 | chan->fcs = pchan->fcs; | 1010 | chan->fcs = pchan->fcs; |
1003 | chan->max_tx = pchan->max_tx; | 1011 | chan->max_tx = pchan->max_tx; |
1004 | chan->tx_win = pchan->tx_win; | 1012 | chan->tx_win = pchan->tx_win; |
@@ -1007,13 +1015,13 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
1007 | chan->force_reliable = pchan->force_reliable; | 1015 | chan->force_reliable = pchan->force_reliable; |
1008 | chan->flushable = pchan->flushable; | 1016 | chan->flushable = pchan->flushable; |
1009 | } else { | 1017 | } else { |
1010 | pi->imtu = L2CAP_DEFAULT_MTU; | 1018 | chan->imtu = L2CAP_DEFAULT_MTU; |
1011 | pi->omtu = 0; | 1019 | chan->omtu = 0; |
1012 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { | 1020 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { |
1013 | pi->mode = L2CAP_MODE_ERTM; | 1021 | chan->mode = L2CAP_MODE_ERTM; |
1014 | chan->conf_state |= L2CAP_CONF_STATE2_DEVICE; | 1022 | chan->conf_state |= L2CAP_CONF_STATE2_DEVICE; |
1015 | } else { | 1023 | } else { |
1016 | pi->mode = L2CAP_MODE_BASIC; | 1024 | chan->mode = L2CAP_MODE_BASIC; |
1017 | } | 1025 | } |
1018 | chan->max_tx = L2CAP_DEFAULT_MAX_TX; | 1026 | chan->max_tx = L2CAP_DEFAULT_MAX_TX; |
1019 | chan->fcs = L2CAP_FCS_CRC16; | 1027 | chan->fcs = L2CAP_FCS_CRC16; |
@@ -1025,7 +1033,7 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
1025 | } | 1033 | } |
1026 | 1034 | ||
1027 | /* Default config options */ | 1035 | /* Default config options */ |
1028 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; | 1036 | chan->flush_to = L2CAP_DEFAULT_FLUSH_TO; |
1029 | } | 1037 | } |
1030 | 1038 | ||
1031 | static struct proto l2cap_proto = { | 1039 | static struct proto l2cap_proto = { |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 4f728a4f7177..fdd8f5ab18c1 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -710,10 +710,10 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, | |||
710 | /* Set L2CAP options */ | 710 | /* Set L2CAP options */ |
711 | sk = sock->sk; | 711 | sk = sock->sk; |
712 | lock_sock(sk); | 712 | lock_sock(sk); |
713 | l2cap_pi(sk)->imtu = l2cap_mtu; | 713 | l2cap_pi(sk)->chan->imtu = l2cap_mtu; |
714 | l2cap_pi(sk)->chan->sec_level = sec_level; | 714 | l2cap_pi(sk)->chan->sec_level = sec_level; |
715 | if (l2cap_ertm) | 715 | if (l2cap_ertm) |
716 | l2cap_pi(sk)->mode = L2CAP_MODE_ERTM; | 716 | l2cap_pi(sk)->chan->mode = L2CAP_MODE_ERTM; |
717 | release_sock(sk); | 717 | release_sock(sk); |
718 | 718 | ||
719 | s = rfcomm_session_add(sock, BT_BOUND); | 719 | s = rfcomm_session_add(sock, BT_BOUND); |
@@ -1890,7 +1890,8 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s) | |||
1890 | 1890 | ||
1891 | /* We should adjust MTU on incoming sessions. | 1891 | /* We should adjust MTU on incoming sessions. |
1892 | * L2CAP MTU minus UIH header and FCS. */ | 1892 | * L2CAP MTU minus UIH header and FCS. */ |
1893 | s->mtu = min(l2cap_pi(nsock->sk)->omtu, l2cap_pi(nsock->sk)->imtu) - 5; | 1893 | s->mtu = min(l2cap_pi(nsock->sk)->chan->omtu, |
1894 | l2cap_pi(nsock->sk)->chan->imtu) - 5; | ||
1894 | 1895 | ||
1895 | rfcomm_schedule(); | 1896 | rfcomm_schedule(); |
1896 | } else | 1897 | } else |
@@ -1909,7 +1910,7 @@ static inline void rfcomm_check_connection(struct rfcomm_session *s) | |||
1909 | 1910 | ||
1910 | /* We can adjust MTU on outgoing sessions. | 1911 | /* We can adjust MTU on outgoing sessions. |
1911 | * L2CAP MTU minus UIH header and FCS. */ | 1912 | * L2CAP MTU minus UIH header and FCS. */ |
1912 | s->mtu = min(l2cap_pi(sk)->omtu, l2cap_pi(sk)->imtu) - 5; | 1913 | s->mtu = min(l2cap_pi(sk)->chan->omtu, l2cap_pi(sk)->chan->imtu) - 5; |
1913 | 1914 | ||
1914 | rfcomm_send_sabm(s, 0); | 1915 | rfcomm_send_sabm(s, 0); |
1915 | break; | 1916 | break; |
@@ -1992,7 +1993,7 @@ static int rfcomm_add_listener(bdaddr_t *ba) | |||
1992 | /* Set L2CAP options */ | 1993 | /* Set L2CAP options */ |
1993 | sk = sock->sk; | 1994 | sk = sock->sk; |
1994 | lock_sock(sk); | 1995 | lock_sock(sk); |
1995 | l2cap_pi(sk)->imtu = l2cap_mtu; | 1996 | l2cap_pi(sk)->chan->imtu = l2cap_mtu; |
1996 | release_sock(sk); | 1997 | release_sock(sk); |
1997 | 1998 | ||
1998 | /* Start listening on the socket */ | 1999 | /* Start listening on the socket */ |