Skip to contentSkip to conversation

Bluetooth: Fix respecting le_default_mps value

PATCH In review [email protected] 2 participants 6 messages Jan 27, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Bluetooth: Fix respecting le_default_mps value

From: Johan Hedberg <[email protected]>

There's a le_default_mps variable that can be modified through debugfs but it was never actually used for determining our MPS value. This patch fixes the MPS initialization to use the variable instead of a fixed value.

---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +1 -1
index cc340700573e..5a30fc72f4ba 100644
@@ -482,7 +482,7 @@ static void l2cap_le_flowctl_init(struct l2cap_chan *chan)
 	chan->sdu_len = 0;
 	chan->tx_credits = 0;
 	chan->rx_credits = le_max_credits;
-	chan->mps = min_t(u16, chan->imtu, L2CAP_LE_DEFAULT_MPS);
+	chan->mps = min_t(u16, chan->imtu, le_default_mps);
 
 	skb_queue_head_init(&chan->tx_q);
 }
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 2/3 Bluetooth: Fix disconnecting L2CAP channel for credits violation

From: Johan Hedberg <[email protected]>

The L2CAP specification requires us to disconnect a channel if the remote device sends us data when it doesn't have any credits to do so. This patch makes sure that we send the appropriate L2CAP Disconnect request in this situation.

---
 net/bluetooth/l2cap_core.c | 1 +
 1 file changed, 1 insertion(+)
net/bluetooth/l2cap_core.c +1 -0
index 5a30fc72f4ba..fbc9709abccf 100644
@@ -6635,6 +6635,7 @@ static int l2cap_le_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
 
 	if (!chan->rx_credits) {
 		BT_ERR("No credits to receive LE L2CAP data");
+		l2cap_send_disconn_req(chan, ECONNRESET);
 		return -ENOBUFS;
 	}
 
Signature · 1 line
1.8.5.3
#3 lore raw

PATCH 3/3 Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs

In reply to [email protected]

From: Johan Hedberg <[email protected]>

The L2CAP specification requires us to disconnect an L2CAP channel if the remote side gives us credits beyond 65535. This patch makes sure we disconnect the channel in such a situation.

---
 net/bluetooth/l2cap_core.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +14 -1
index fbc9709abccf..d2ef49b54aa2 100644
@@ -42,6 +42,8 @@
 #include "amp.h"
 #include "6lowpan.h"
 
+#define LE_FLOWCTL_MAX_CREDITS 65535
+
 bool disable_ertm;
 
 static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN | L2CAP_FEAT_UCD;
@@ -5473,7 +5475,7 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,
 {
 	struct l2cap_le_credits *pkt;
 	struct l2cap_chan *chan;
-	u16 cid, credits;
+	u16 cid, credits, max_credits;
 
 	if (cmd_len != sizeof(*pkt))
 		return -EPROTO;
@@ -5488,6 +5490,17 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,
 	if (!chan)
 		return -EBADSLT;
 
+	max_credits = LE_FLOWCTL_MAX_CREDITS - chan->tx_credits;
+	if (credits > max_credits) {
+		BT_ERR("LE credits overflow");
+		l2cap_send_disconn_req(chan, ECONNRESET);
+
+		/* Return 0 so that we don't trigger an unnecessary
+		 * command reject packet.
+		 */
+		return 0;
+	}
+
 	chan->tx_credits += credits;
 
 	while (chan->tx_credits && !skb_queue_empty(&chan->tx_q)) {
Signature · 1 line
1.8.5.3
maintainer
#5 lore raw
In reply to [email protected]

Hi Johan,

Quoted 9 lines

There's a le_default_mps variable that can be modified through debugfs but it was never actually used for determining our MPS value. This patch fixes the MPS initialization to use the variable instead of a fixed value.

---
net/bluetooth/l2cap_core.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#2 lore raw

Re: [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation

In reply to [email protected]

Hi Johan,

Quoted 9 lines

The L2CAP specification requires us to disconnect a channel if the remote device sends us data when it doesn't have any credits to do so. This patch makes sure that we send the appropriate L2CAP Disconnect request in this situation.

---
net/bluetooth/l2cap_core.c | 1 +

1 file changed, 1 insertion(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#4 lore raw

Re: [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs

In reply to [email protected]

Hi Johan,

Quoted 8 lines

The L2CAP specification requires us to disconnect an L2CAP channel if the remote side gives us credits beyond 65535. This patch makes sure we disconnect the channel in such a situation.

---
net/bluetooth/l2cap_core.c | 15 ++++++++++++++-

1 file changed, 14 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel