Skip to content

Commit

Permalink
Bluetooth: L2CAP: Add module option to enable ECRED mode
Browse files Browse the repository at this point in the history
This should make it safe to have the code upstream without affecting
stable systems since there are a few details not sort out with ECRED
mode e.g: how to initiate multiple connections at once.

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
Vudentz authored and holtmann committed Mar 8, 2020
1 parent 15f02b9 commit 4be5ca6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
}

extern bool disable_ertm;
extern bool enable_ecred;

int l2cap_init_sockets(void);
void l2cap_cleanup_sockets(void);
Expand Down
15 changes: 15 additions & 0 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define LE_FLOWCTL_MAX_CREDITS 65535

bool disable_ertm;
bool enable_ecred;

static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN | L2CAP_FEAT_UCD;

Expand Down Expand Up @@ -5849,6 +5850,9 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
int i, num_scid;
bool defer = false;

if (!enable_ecred)
return -EINVAL;

if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
result = L2CAP_CR_LE_INVALID_PARAMS;
goto response;
Expand Down Expand Up @@ -6092,6 +6096,9 @@ static inline int l2cap_ecred_reconf_req(struct l2cap_conn *conn,
struct l2cap_chan *chan;
int i, num_scid;

if (!enable_ecred)
return -EINVAL;

if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
result = L2CAP_CR_LE_INVALID_PARAMS;
goto respond;
Expand Down Expand Up @@ -7723,7 +7730,12 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
case L2CAP_MODE_BASIC:
break;
case L2CAP_MODE_LE_FLOWCTL:
break;
case L2CAP_MODE_EXT_FLOWCTL:
if (!enable_ecred) {
err = -EOPNOTSUPP;
goto done;
}
break;
case L2CAP_MODE_ERTM:
case L2CAP_MODE_STREAMING:
Expand Down Expand Up @@ -8301,3 +8313,6 @@ void l2cap_exit(void)

module_param(disable_ertm, bool, 0644);
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");

module_param(enable_ecred, bool, 0644);
MODULE_PARM_DESC(enable_ecred, "Enable enhanced credit flow control mode");
5 changes: 5 additions & 0 deletions net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,12 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
switch (chan->mode) {
case L2CAP_MODE_BASIC:
case L2CAP_MODE_LE_FLOWCTL:
break;
case L2CAP_MODE_EXT_FLOWCTL:
if (!enable_ecred) {
err = -EOPNOTSUPP;
goto done;
}
break;
case L2CAP_MODE_ERTM:
case L2CAP_MODE_STREAMING:
Expand Down

0 comments on commit 4be5ca6

Please sign in to comment.