Commit 8c1d787b authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: Move conn to struct l2cap_chan

There is no need to the socket deal directly with the channel, most of the
time it cares about the channel only.
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent fe4128e0
...@@ -284,6 +284,9 @@ struct srej_list { ...@@ -284,6 +284,9 @@ struct srej_list {
struct l2cap_chan { struct l2cap_chan {
struct sock *sk; struct sock *sk;
struct l2cap_conn *conn;
__le16 psm; __le16 psm;
__u16 dcid; __u16 dcid;
__u16 scid; __u16 scid;
...@@ -385,8 +388,6 @@ struct l2cap_conn { ...@@ -385,8 +388,6 @@ struct l2cap_conn {
struct l2cap_pinfo { struct l2cap_pinfo {
struct bt_sock bt; struct bt_sock bt;
struct l2cap_conn *conn;
struct l2cap_chan *chan; struct l2cap_chan *chan;
}; };
...@@ -447,7 +448,7 @@ int l2cap_init_sockets(void); ...@@ -447,7 +448,7 @@ int l2cap_init_sockets(void);
void l2cap_cleanup_sockets(void); void l2cap_cleanup_sockets(void);
void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
void __l2cap_connect_rsp_defer(struct sock *sk); void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
int __l2cap_wait_ack(struct sock *sk); int __l2cap_wait_ack(struct sock *sk);
struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
......
...@@ -169,7 +169,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) ...@@ -169,7 +169,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
conn->disc_reason = 0x13; conn->disc_reason = 0x13;
l2cap_pi(sk)->conn = conn; chan->conn = conn;
if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) { if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) {
if (conn->hcon->type == LE_LINK) { if (conn->hcon->type == LE_LINK) {
...@@ -204,7 +204,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) ...@@ -204,7 +204,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
void l2cap_chan_del(struct l2cap_chan *chan, int err) void l2cap_chan_del(struct l2cap_chan *chan, int err)
{ {
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
struct sock *parent = bt_sk(sk)->parent; struct sock *parent = bt_sk(sk)->parent;
l2cap_sock_clear_timer(sk); l2cap_sock_clear_timer(sk);
...@@ -218,7 +218,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) ...@@ -218,7 +218,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
write_unlock_bh(&conn->chan_lock); write_unlock_bh(&conn->chan_lock);
__sock_put(sk); __sock_put(sk);
l2cap_pi(sk)->conn = NULL; chan->conn = NULL;
hci_conn_put(conn->hcon); hci_conn_put(conn->hcon);
} }
...@@ -296,7 +296,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) ...@@ -296,7 +296,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan)
/* Service level security */ /* Service level security */
static inline int l2cap_check_security(struct l2cap_chan *chan) static inline int l2cap_check_security(struct l2cap_chan *chan)
{ {
struct l2cap_conn *conn = l2cap_pi(chan->sk)->conn; struct l2cap_conn *conn = chan->conn;
__u8 auth_type; __u8 auth_type;
auth_type = l2cap_get_auth_type(chan); auth_type = l2cap_get_auth_type(chan);
...@@ -349,7 +349,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) ...@@ -349,7 +349,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
struct sk_buff *skb; struct sk_buff *skb;
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
struct l2cap_pinfo *pi = l2cap_pi(chan->sk); struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
struct l2cap_conn *conn = pi->conn; struct l2cap_conn *conn = chan->conn;
struct sock *sk = (struct sock *)pi; struct sock *sk = (struct sock *)pi;
int count, hlen = L2CAP_HDR_SIZE + 2; int count, hlen = L2CAP_HDR_SIZE + 2;
u8 flags; u8 flags;
...@@ -394,7 +394,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) ...@@ -394,7 +394,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
else else
flags = ACL_START; flags = ACL_START;
hci_send_acl(pi->conn->hcon, skb, flags); hci_send_acl(chan->conn->hcon, skb, flags);
} }
static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control)
...@@ -417,8 +417,7 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) ...@@ -417,8 +417,7 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan)
static void l2cap_do_start(struct l2cap_chan *chan) static void l2cap_do_start(struct l2cap_chan *chan)
{ {
struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn;
struct l2cap_conn *conn = l2cap_pi(sk)->conn;
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) { if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) {
if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)) if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
...@@ -920,12 +919,13 @@ int l2cap_chan_connect(struct l2cap_chan *chan) ...@@ -920,12 +919,13 @@ int l2cap_chan_connect(struct l2cap_chan *chan)
int __l2cap_wait_ack(struct sock *sk) int __l2cap_wait_ack(struct sock *sk)
{ {
struct l2cap_chan *chan = l2cap_pi(sk)->chan;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int err = 0; int err = 0;
int timeo = HZ/5; int timeo = HZ/5;
add_wait_queue(sk_sleep(sk), &wait); add_wait_queue(sk_sleep(sk), &wait);
while ((l2cap_pi(sk)->chan->unacked_frames > 0 && l2cap_pi(sk)->conn)) { while ((chan->unacked_frames > 0 && chan->conn)) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (!timeo) if (!timeo)
...@@ -958,7 +958,7 @@ static void l2cap_monitor_timeout(unsigned long arg) ...@@ -958,7 +958,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
bh_lock_sock(sk); bh_lock_sock(sk);
if (chan->retry_count >= chan->remote_max_tx) { if (chan->retry_count >= chan->remote_max_tx) {
l2cap_send_disconn_req(l2cap_pi(sk)->conn, chan, ECONNABORTED); l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
bh_unlock_sock(sk); bh_unlock_sock(sk);
return; return;
} }
...@@ -1008,8 +1008,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan) ...@@ -1008,8 +1008,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
{ {
struct sock *sk = chan->sk; struct hci_conn *hcon = chan->conn->hcon;
struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
u16 flags; u16 flags;
BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len);
...@@ -1045,8 +1044,6 @@ void l2cap_streaming_send(struct l2cap_chan *chan) ...@@ -1045,8 +1044,6 @@ void l2cap_streaming_send(struct l2cap_chan *chan)
static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
{ {
struct sock *sk = chan->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk);
struct sk_buff *skb, *tx_skb; struct sk_buff *skb, *tx_skb;
u16 control, fcs; u16 control, fcs;
...@@ -1065,7 +1062,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) ...@@ -1065,7 +1062,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
if (chan->remote_max_tx && if (chan->remote_max_tx &&
bt_cb(skb)->retries == chan->remote_max_tx) { bt_cb(skb)->retries == chan->remote_max_tx) {
l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED); l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
return; return;
} }
...@@ -1096,7 +1093,6 @@ int l2cap_ertm_send(struct l2cap_chan *chan) ...@@ -1096,7 +1093,6 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
{ {
struct sk_buff *skb, *tx_skb; struct sk_buff *skb, *tx_skb;
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk);
u16 control, fcs; u16 control, fcs;
int nsent = 0; int nsent = 0;
...@@ -1107,7 +1103,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan) ...@@ -1107,7 +1103,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
if (chan->remote_max_tx && if (chan->remote_max_tx &&
bt_cb(skb)->retries == chan->remote_max_tx) { bt_cb(skb)->retries == chan->remote_max_tx) {
l2cap_send_disconn_req(pi->conn, chan, ECONNABORTED); l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
break; break;
} }
...@@ -1203,7 +1199,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan) ...@@ -1203,7 +1199,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan)
static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb) static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, int len, int count, struct sk_buff *skb)
{ {
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
struct sk_buff **frag; struct sk_buff **frag;
int err, sent = 0; int err, sent = 0;
...@@ -1236,7 +1232,7 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in ...@@ -1236,7 +1232,7 @@ static inline int l2cap_skbuff_fromiovec(struct sock *sk, struct msghdr *msg, in
struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
{ {
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
struct sk_buff *skb; struct sk_buff *skb;
int err, count, hlen = L2CAP_HDR_SIZE + 2; int err, count, hlen = L2CAP_HDR_SIZE + 2;
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
...@@ -1266,7 +1262,7 @@ struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr ...@@ -1266,7 +1262,7 @@ struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr
struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
{ {
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
struct sk_buff *skb; struct sk_buff *skb;
int err, count, hlen = L2CAP_HDR_SIZE; int err, count, hlen = L2CAP_HDR_SIZE;
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
...@@ -1295,7 +1291,7 @@ struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *m ...@@ -1295,7 +1291,7 @@ struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *m
struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen) struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen)
{ {
struct sock *sk = chan->sk; struct sock *sk = chan->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
struct sk_buff *skb; struct sk_buff *skb;
int err, count, hlen = L2CAP_HDR_SIZE + 2; int err, count, hlen = L2CAP_HDR_SIZE + 2;
struct l2cap_hdr *lh; struct l2cap_hdr *lh;
...@@ -1611,7 +1607,6 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask) ...@@ -1611,7 +1607,6 @@ static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
{ {
struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
struct l2cap_conf_req *req = data; struct l2cap_conf_req *req = data;
struct l2cap_conf_rfc rfc = { .mode = chan->mode }; struct l2cap_conf_rfc rfc = { .mode = chan->mode };
void *ptr = req->data; void *ptr = req->data;
...@@ -1629,7 +1624,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1629,7 +1624,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
/* fall through */ /* fall through */
default: default:
chan->mode = l2cap_select_mode(rfc.mode, pi->conn->feat_mask); chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask);
break; break;
} }
...@@ -1639,8 +1634,8 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1639,8 +1634,8 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
switch (chan->mode) { switch (chan->mode) {
case L2CAP_MODE_BASIC: case L2CAP_MODE_BASIC:
if (!(pi->conn->feat_mask & L2CAP_FEAT_ERTM) && if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) &&
!(pi->conn->feat_mask & L2CAP_FEAT_STREAMING)) !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING))
break; break;
rfc.mode = L2CAP_MODE_BASIC; rfc.mode = L2CAP_MODE_BASIC;
...@@ -1661,13 +1656,13 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1661,13 +1656,13 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
rfc.retrans_timeout = 0; rfc.retrans_timeout = 0;
rfc.monitor_timeout = 0; rfc.monitor_timeout = 0;
rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE);
if (L2CAP_DEFAULT_MAX_PDU_SIZE > pi->conn->mtu - 10) if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
(unsigned long) &rfc); (unsigned long) &rfc);
if (!(pi->conn->feat_mask & L2CAP_FEAT_FCS)) if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
break; break;
if (chan->fcs == L2CAP_FCS_NONE || if (chan->fcs == L2CAP_FCS_NONE ||
...@@ -1684,13 +1679,13 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1684,13 +1679,13 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
rfc.retrans_timeout = 0; rfc.retrans_timeout = 0;
rfc.monitor_timeout = 0; rfc.monitor_timeout = 0;
rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE);
if (L2CAP_DEFAULT_MAX_PDU_SIZE > pi->conn->mtu - 10) if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc),
(unsigned long) &rfc); (unsigned long) &rfc);
if (!(pi->conn->feat_mask & L2CAP_FEAT_FCS)) if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS))
break; break;
if (chan->fcs == L2CAP_FCS_NONE || if (chan->fcs == L2CAP_FCS_NONE ||
...@@ -1709,7 +1704,6 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1709,7 +1704,6 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
{ {
struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
struct l2cap_conf_rsp *rsp = data; struct l2cap_conf_rsp *rsp = data;
void *ptr = rsp->data; void *ptr = rsp->data;
void *req = chan->conf_req; void *req = chan->conf_req;
...@@ -1769,7 +1763,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1769,7 +1763,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
case L2CAP_MODE_ERTM: case L2CAP_MODE_ERTM:
if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) {
chan->mode = l2cap_select_mode(rfc.mode, chan->mode = l2cap_select_mode(rfc.mode,
pi->conn->feat_mask); chan->conn->feat_mask);
break; break;
} }
...@@ -1814,8 +1808,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1814,8 +1808,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
chan->remote_tx_win = rfc.txwin_size; chan->remote_tx_win = rfc.txwin_size;
chan->remote_max_tx = rfc.max_transmit; chan->remote_max_tx = rfc.max_transmit;
if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
...@@ -1832,8 +1826,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) ...@@ -1832,8 +1826,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
break; break;
case L2CAP_MODE_STREAMING: case L2CAP_MODE_STREAMING:
if (le16_to_cpu(rfc.max_pdu_size) > pi->conn->mtu - 10) if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10)
rfc.max_pdu_size = cpu_to_le16(pi->conn->mtu - 10); rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10);
chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); chan->remote_mps = le16_to_cpu(rfc.max_pdu_size);
...@@ -1943,15 +1937,12 @@ static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, ...@@ -1943,15 +1937,12 @@ static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result,
return ptr - data; return ptr - data;
} }
void __l2cap_connect_rsp_defer(struct sock *sk) void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
{ {
struct l2cap_conn_rsp rsp; struct l2cap_conn_rsp rsp;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
struct l2cap_chan *chan = l2cap_pi(sk)->chan;
u8 buf[128]; u8 buf[128];
sk->sk_state = BT_CONFIG;
rsp.scid = cpu_to_le16(chan->dcid); rsp.scid = cpu_to_le16(chan->dcid);
rsp.dcid = cpu_to_le16(chan->scid); rsp.dcid = cpu_to_le16(chan->scid);
rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
...@@ -2856,7 +2847,6 @@ static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, ...@@ -2856,7 +2847,6 @@ static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb,
static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control)
{ {
struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
struct sk_buff *_skb; struct sk_buff *_skb;
int err; int err;
...@@ -2957,7 +2947,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk ...@@ -2957,7 +2947,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk
chan->sdu = NULL; chan->sdu = NULL;
disconnect: disconnect:
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
...@@ -3018,7 +3008,7 @@ static void l2cap_busy_work(struct work_struct *work) ...@@ -3018,7 +3008,7 @@ static void l2cap_busy_work(struct work_struct *work)
if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) { if (n_tries++ > L2CAP_LOCAL_BUSY_TRIES) {
err = -EBUSY; err = -EBUSY;
l2cap_send_disconn_req(l2cap_pi(sk)->conn, chan, EBUSY); l2cap_send_disconn_req(chan->conn, chan, EBUSY);
break; break;
} }
...@@ -3236,7 +3226,6 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) ...@@ -3236,7 +3226,6 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq)
static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
{ {
struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
u8 tx_seq = __get_txseq(rx_control); u8 tx_seq = __get_txseq(rx_control);
u8 req_seq = __get_reqseq(rx_control); u8 req_seq = __get_reqseq(rx_control);
u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT;
...@@ -3267,7 +3256,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont ...@@ -3267,7 +3256,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
/* invalid tx_seq */ /* invalid tx_seq */
if (tx_seq_offset >= chan->tx_win) { if (tx_seq_offset >= chan->tx_win) {
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
goto drop; goto drop;
} }
...@@ -3534,7 +3523,6 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont ...@@ -3534,7 +3523,6 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont
static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
{ {
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
struct l2cap_pinfo *pi = l2cap_pi(sk);
u16 control; u16 control;
u8 req_seq; u8 req_seq;
int len, next_tx_seq_offset, req_seq_offset; int len, next_tx_seq_offset, req_seq_offset;
...@@ -3558,7 +3546,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -3558,7 +3546,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
len -= 2; len -= 2;
if (len > chan->mps) { if (len > chan->mps) {
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
goto drop; goto drop;
} }
...@@ -3574,13 +3562,13 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -3574,13 +3562,13 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
/* check for invalid req-seq */ /* check for invalid req-seq */
if (req_seq_offset > next_tx_seq_offset) { if (req_seq_offset > next_tx_seq_offset) {
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
goto drop; goto drop;
} }
if (__is_iframe(control)) { if (__is_iframe(control)) {
if (len < 0) { if (len < 0) {
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
goto drop; goto drop;
} }
...@@ -3588,7 +3576,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -3588,7 +3576,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
} else { } else {
if (len != 0) { if (len != 0) {
BT_ERR("%d", len); BT_ERR("%d", len);
l2cap_send_disconn_req(pi->conn, chan, ECONNRESET); l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
goto drop; goto drop;
} }
......
...@@ -455,8 +455,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us ...@@ -455,8 +455,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
break; break;
} }
cinfo.hci_handle = l2cap_pi(sk)->conn->hcon->handle; cinfo.hci_handle = chan->conn->hcon->handle;
memcpy(cinfo.dev_class, l2cap_pi(sk)->conn->hcon->dev_class, 3); memcpy(cinfo.dev_class, chan->conn->hcon->dev_class, 3);
len = min_t(unsigned int, len, sizeof(cinfo)); len = min_t(unsigned int, len, sizeof(cinfo));
if (copy_to_user(optval, (char *) &cinfo, len)) if (copy_to_user(optval, (char *) &cinfo, len))
...@@ -690,7 +690,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch ...@@ -690,7 +690,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
} }
if (opt == BT_FLUSHABLE_OFF) { if (opt == BT_FLUSHABLE_OFF) {
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = chan->conn;
/* proceed futher only when we have l2cap_conn and /* proceed futher only when we have l2cap_conn and
No Flush support in the LM */ No Flush support in the LM */
if (!conn || !lmp_no_flush_capable(conn->hcon->hdev)) { if (!conn || !lmp_no_flush_capable(conn->hcon->hdev)) {
...@@ -823,7 +823,9 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms ...@@ -823,7 +823,9 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
lock_sock(sk); lock_sock(sk);
if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) { if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
__l2cap_connect_rsp_defer(sk); sk->sk_state = BT_CONFIG;
__l2cap_connect_rsp_defer(l2cap_pi(sk)->chan);
release_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -878,8 +880,8 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) ...@@ -878,8 +880,8 @@ static void l2cap_sock_cleanup_listen(struct sock *parent)
void __l2cap_sock_close(struct sock *sk, int reason) void __l2cap_sock_close(struct sock *sk, int reason)
{ {
struct l2cap_conn *conn = l2cap_pi(sk)->conn;
struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct l2cap_chan *chan = l2cap_pi(sk)->chan;
struct l2cap_conn *conn = chan->conn;
BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
......
...@@ -232,6 +232,8 @@ static int rfcomm_l2sock_create(struct socket **sock) ...@@ -232,6 +232,8 @@ static int rfcomm_l2sock_create(struct socket **sock)
static inline int rfcomm_check_security(struct rfcomm_dlc *d) static inline int rfcomm_check_security(struct rfcomm_dlc *d)
{ {
struct sock *sk = d->session->sock->sk; struct sock *sk = d->session->sock->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
__u8 auth_type; __u8 auth_type;
switch (d->sec_level) { switch (d->sec_level) {
...@@ -246,8 +248,7 @@ static inline int rfcomm_check_security(struct rfcomm_dlc *d) ...@@ -246,8 +248,7 @@ static inline int rfcomm_check_security(struct rfcomm_dlc *d)
break; break;
} }
return hci_conn_security(l2cap_pi(sk)->conn->hcon, d->sec_level, return hci_conn_security(conn->hcon, d->sec_level, auth_type);
auth_type);
} }
static void rfcomm_session_timeout(unsigned long arg) static void rfcomm_session_timeout(unsigned long arg)
...@@ -1241,6 +1242,7 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci) ...@@ -1241,6 +1242,7 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci)
void rfcomm_dlc_accept(struct rfcomm_dlc *d) void rfcomm_dlc_accept(struct rfcomm_dlc *d)
{ {
struct sock *sk = d->session->sock->sk; struct sock *sk = d->session->sock->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
BT_DBG("dlc %p", d); BT_DBG("dlc %p", d);
...@@ -1254,7 +1256,7 @@ void rfcomm_dlc_accept(struct rfcomm_dlc *d) ...@@ -1254,7 +1256,7 @@ void rfcomm_dlc_accept(struct rfcomm_dlc *d)
rfcomm_dlc_unlock(d); rfcomm_dlc_unlock(d);
if (d->role_switch) if (d->role_switch)
hci_conn_switch_role(l2cap_pi(sk)->conn->hcon, 0x00); hci_conn_switch_role(conn->hcon, 0x00);
rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig);
} }
......
...@@ -743,6 +743,7 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u ...@@ -743,6 +743,7 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct sock *l2cap_sk; struct sock *l2cap_sk;
struct rfcomm_conninfo cinfo; struct rfcomm_conninfo cinfo;
struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
int len, err = 0; int len, err = 0;
u32 opt; u32 opt;
...@@ -787,8 +788,8 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u ...@@ -787,8 +788,8 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u
l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk; l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk;
cinfo.hci_handle = l2cap_pi(l2cap_sk)->conn->hcon->handle; cinfo.hci_handle = conn->hcon->handle;
memcpy(cinfo.dev_class, l2cap_pi(l2cap_sk)->conn->hcon->dev_class, 3); memcpy(cinfo.dev_class, conn->hcon->dev_class, 3);
len = min_t(unsigned int, len, sizeof(cinfo)); len = min_t(unsigned int, len, sizeof(cinfo));
if (copy_to_user(optval, (char *) &cinfo, len)) if (copy_to_user(optval, (char *) &cinfo, len))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment