Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value
@ 2014-01-27 23:11 johan.hedberg
  2014-01-27 23:11 ` [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation johan.hedberg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: johan.hedberg @ 2014-01-27 23:11 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

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.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index cc340700573e..5a30fc72f4ba 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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);
 }
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation
  2014-01-27 23:11 [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value johan.hedberg
@ 2014-01-27 23:11 ` johan.hedberg
  2014-01-27 23:32   ` Marcel Holtmann
  2014-01-27 23:11 ` [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs johan.hedberg
  2014-01-27 23:30 ` [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value Marcel Holtmann
  2 siblings, 1 reply; 6+ messages in thread
From: johan.hedberg @ 2014-01-27 23:11 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

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.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5a30fc72f4ba..fbc9709abccf 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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;
 	}
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs
  2014-01-27 23:11 [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value johan.hedberg
  2014-01-27 23:11 ` [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation johan.hedberg
@ 2014-01-27 23:11 ` johan.hedberg
  2014-01-27 23:36   ` Marcel Holtmann
  2014-01-27 23:30 ` [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value Marcel Holtmann
  2 siblings, 1 reply; 6+ messages in thread
From: johan.hedberg @ 2014-01-27 23:11 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

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.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fbc9709abccf..d2ef49b54aa2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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)) {
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value
  2014-01-27 23:11 [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value johan.hedberg
  2014-01-27 23:11 ` [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation johan.hedberg
  2014-01-27 23:11 ` [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs johan.hedberg
@ 2014-01-27 23:30 ` Marcel Holtmann
  2 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2014-01-27 23:30 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development

Hi Johan,

> 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.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation
  2014-01-27 23:11 ` [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation johan.hedberg
@ 2014-01-27 23:32   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2014-01-27 23:32 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development

Hi Johan,

> 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.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 1 +
> 1 file changed, 1 insertion(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs
  2014-01-27 23:11 ` [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs johan.hedberg
@ 2014-01-27 23:36   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2014-01-27 23:36 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: BlueZ development

Hi Johan,

> 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.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-27 23:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 23:11 [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value johan.hedberg
2014-01-27 23:11 ` [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation johan.hedberg
2014-01-27 23:32   ` Marcel Holtmann
2014-01-27 23:11 ` [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs johan.hedberg
2014-01-27 23:36   ` Marcel Holtmann
2014-01-27 23:30 ` [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox