mirror of https://gitee.com/openkylin/linux.git
Bluetooth: Switch ATT channels to use L2CAP_CHAN_FIXED
ATT channels are not connection oriented so having them use L2CAP_CHAN_CONN_ORIENTED is quite confusing. Instead, use the new L2CAP_CHAN_FIXED type and ensure that the MTU and CID values get properly set. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
2338a7e044
commit
21626e6214
|
@ -498,18 +498,10 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
|
||||||
|
|
||||||
switch (chan->chan_type) {
|
switch (chan->chan_type) {
|
||||||
case L2CAP_CHAN_CONN_ORIENTED:
|
case L2CAP_CHAN_CONN_ORIENTED:
|
||||||
if (conn->hcon->type == LE_LINK) {
|
/* Alloc CID for connection-oriented socket */
|
||||||
if (chan->dcid == L2CAP_CID_ATT) {
|
chan->scid = l2cap_alloc_cid(conn);
|
||||||
chan->omtu = L2CAP_DEFAULT_MTU;
|
if (conn->hcon->type == ACL_LINK)
|
||||||
chan->scid = L2CAP_CID_ATT;
|
|
||||||
} else {
|
|
||||||
chan->scid = l2cap_alloc_cid(conn);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Alloc CID for connection-oriented socket */
|
|
||||||
chan->scid = l2cap_alloc_cid(conn);
|
|
||||||
chan->omtu = L2CAP_DEFAULT_MTU;
|
chan->omtu = L2CAP_DEFAULT_MTU;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_CHAN_CONN_LESS:
|
case L2CAP_CHAN_CONN_LESS:
|
||||||
|
@ -7025,7 +7017,12 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && !(psm || cid)) {
|
if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && !psm) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan->chan_type == L2CAP_CHAN_FIXED && !cid) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,15 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
|
||||||
if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
|
if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (la.l2_cid) {
|
||||||
|
/* When the socket gets created it defaults to
|
||||||
|
* CHAN_CONN_ORIENTED, so we need to overwrite the
|
||||||
|
* default here.
|
||||||
|
*/
|
||||||
|
chan->chan_type = L2CAP_CHAN_FIXED;
|
||||||
|
chan->omtu = L2CAP_DEFAULT_MTU;
|
||||||
|
}
|
||||||
|
|
||||||
if (bdaddr_type_is_le(la.l2_bdaddr_type)) {
|
if (bdaddr_type_is_le(la.l2_bdaddr_type)) {
|
||||||
if (!enable_lecoc && la.l2_psm)
|
if (!enable_lecoc && la.l2_psm)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Reference in New Issue