Skip to content

Commit 4be5ca6

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: L2CAP: Add module option to enable ECRED mode
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 <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 15f02b9 commit 4be5ca6

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
958958
}
959959

960960
extern bool disable_ertm;
961+
extern bool enable_ecred;
961962

962963
int l2cap_init_sockets(void);
963964
void l2cap_cleanup_sockets(void);

‎net/bluetooth/l2cap_core.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define LE_FLOWCTL_MAX_CREDITS 65535
4646

4747
bool disable_ertm;
48+
bool enable_ecred;
4849

4950
static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN | L2CAP_FEAT_UCD;
5051

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

5853+
if (!enable_ecred)
5854+
return -EINVAL;
5855+
58525856
if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
58535857
result = L2CAP_CR_LE_INVALID_PARAMS;
58545858
goto response;
@@ -6092,6 +6096,9 @@ static inline int l2cap_ecred_reconf_req(struct l2cap_conn *conn,
60926096
struct l2cap_chan *chan;
60936097
int i, num_scid;
60946098

6099+
if (!enable_ecred)
6100+
return -EINVAL;
6101+
60956102
if (cmd_len < sizeof(*req) || cmd_len - sizeof(*req) % sizeof(u16)) {
60966103
result = L2CAP_CR_LE_INVALID_PARAMS;
60976104
goto respond;
@@ -7723,7 +7730,12 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
77237730
case L2CAP_MODE_BASIC:
77247731
break;
77257732
case L2CAP_MODE_LE_FLOWCTL:
7733+
break;
77267734
case L2CAP_MODE_EXT_FLOWCTL:
7735+
if (!enable_ecred) {
7736+
err = -EOPNOTSUPP;
7737+
goto done;
7738+
}
77277739
break;
77287740
case L2CAP_MODE_ERTM:
77297741
case L2CAP_MODE_STREAMING:
@@ -8301,3 +8313,6 @@ void l2cap_exit(void)
83018313

83028314
module_param(disable_ertm, bool, 0644);
83038315
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
8316+
8317+
module_param(enable_ecred, bool, 0644);
8318+
MODULE_PARM_DESC(enable_ecred, "Enable enhanced credit flow control mode");

‎net/bluetooth/l2cap_sock.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,12 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
273273
switch (chan->mode) {
274274
case L2CAP_MODE_BASIC:
275275
case L2CAP_MODE_LE_FLOWCTL:
276+
break;
276277
case L2CAP_MODE_EXT_FLOWCTL:
278+
if (!enable_ecred) {
279+
err = -EOPNOTSUPP;
280+
goto done;
281+
}
277282
break;
278283
case L2CAP_MODE_ERTM:
279284
case L2CAP_MODE_STREAMING:

0 commit comments

Comments
 (0)