* [PATCH v2 1/3] Bluetooth: Change default MTU for L2CAP ATT channel
@ 2012-05-31 20:01 Andre Guedes
2012-05-31 20:01 ` [PATCH v2 2/3] Bluetooth: Check MTU value in l2cap_sock_setsockopt_old Andre Guedes
2012-05-31 20:01 ` [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU Andre Guedes
0 siblings, 2 replies; 4+ messages in thread
From: Andre Guedes @ 2012-05-31 20:01 UTC (permalink / raw)
To: linux-bluetooth
This patch changes the default MTU value for L2CAP ATT fixed channel
to L2CAP_DEFAULT_MTU (672 octets).
Differently from others L2CAP channels, in L2CAP ATT fixed channel
there is no MTU negotiation. The MTU value for that channel is up to
the L2CAP implementation. The only restriction in L2CAP spec is the
MTU value must not be less than 23 octets.
At ATT protocol level (on top of L2CAP), we have the ATT_MTU which
defines the maximum size of any ATT message sent between client and
server. GATT profile defines ATT_MTU default value to 23 octets. If
a GATT based profile wants to use ATT_MTU greater than 23 octets
(e.g. HID over GATT profile), it should negotiate a new value by
executing the GATT Exchange MTU sub-procedure.
Thus, in order to support any value of ATT_MTU negotiated at ATT
protocol level, our L2CAP implementation should have L2CAP ATT
fixed channel MTU equal or greater than ATT_MAX_MTU (512 octets).
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
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 9750204..f9bffe3 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -449,7 +449,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
case L2CAP_CHAN_CONN_ORIENTED:
if (conn->hcon->type == LE_LINK) {
/* LE connection */
- chan->omtu = L2CAP_LE_DEFAULT_MTU;
+ chan->omtu = L2CAP_DEFAULT_MTU;
chan->scid = L2CAP_CID_LE_DATA;
chan->dcid = L2CAP_CID_LE_DATA;
} else {
--
1.7.10.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] Bluetooth: Check MTU value in l2cap_sock_setsockopt_old
2012-05-31 20:01 [PATCH v2 1/3] Bluetooth: Change default MTU for L2CAP ATT channel Andre Guedes
@ 2012-05-31 20:01 ` Andre Guedes
2012-05-31 20:01 ` [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU Andre Guedes
1 sibling, 0 replies; 4+ messages in thread
From: Andre Guedes @ 2012-05-31 20:01 UTC (permalink / raw)
To: linux-bluetooth
If user tries to set an invalid MTU value, l2cap_sock_setsockopt_old
should return -EINVAL.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
net/bluetooth/l2cap_sock.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index d856cc8..ab5868d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -445,6 +445,22 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
return err;
}
+static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
+{
+ switch (chan->scid) {
+ case L2CAP_CID_LE_DATA:
+ if (mtu < L2CAP_LE_DEFAULT_MTU)
+ return false;
+ break;
+
+ default:
+ if (mtu < L2CAP_DEFAULT_MIN_MTU)
+ return false;
+ }
+
+ return true;
+}
+
static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
@@ -483,6 +499,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
break;
}
+ if (!l2cap_valid_mtu(chan, opts.imtu)) {
+ err = -EINVAL;
+ break;
+ }
+
chan->mode = opts.mode;
switch (chan->mode) {
case L2CAP_MODE_BASIC:
--
1.7.10.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU
2012-05-31 20:01 [PATCH v2 1/3] Bluetooth: Change default MTU for L2CAP ATT channel Andre Guedes
2012-05-31 20:01 ` [PATCH v2 2/3] Bluetooth: Check MTU value in l2cap_sock_setsockopt_old Andre Guedes
@ 2012-05-31 20:01 ` Andre Guedes
2012-05-31 20:55 ` Gustavo Padovan
1 sibling, 1 reply; 4+ messages in thread
From: Andre Guedes @ 2012-05-31 20:01 UTC (permalink / raw)
To: linux-bluetooth
This patch renames L2CAP_LE_DEFAULT_MTU macro to L2CAP_LE_MIN_MTU
since it represents the minimum MTU value, not the default MTU
value for LE.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_sock.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index a00b43e..ce99c56 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -40,11 +40,11 @@
#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */
#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */
#define L2CAP_DEFAULT_ACK_TO 200
-#define L2CAP_LE_DEFAULT_MTU 23
#define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF
#define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF
#define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF
#define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */
+#define L2CAP_LE_MIN_MTU 23
#define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)
#define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index ab5868d..a4bb27e 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -449,7 +449,7 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
{
switch (chan->scid) {
case L2CAP_CID_LE_DATA:
- if (mtu < L2CAP_LE_DEFAULT_MTU)
+ if (mtu < L2CAP_LE_MIN_MTU)
return false;
break;
--
1.7.10.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU
2012-05-31 20:01 ` [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU Andre Guedes
@ 2012-05-31 20:55 ` Gustavo Padovan
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo Padovan @ 2012-05-31 20:55 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
Hi Andre,
* Andre Guedes <andre.guedes@openbossa.org> [2012-05-31 17:01:35 -0300]:
> This patch renames L2CAP_LE_DEFAULT_MTU macro to L2CAP_LE_MIN_MTU
> since it represents the minimum MTU value, not the default MTU
> value for LE.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/l2cap.h | 2 +-
> net/bluetooth/l2cap_sock.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
All 3 patches have been applied to bluetooth-next, thanks.
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-31 20:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31 20:01 [PATCH v2 1/3] Bluetooth: Change default MTU for L2CAP ATT channel Andre Guedes
2012-05-31 20:01 ` [PATCH v2 2/3] Bluetooth: Check MTU value in l2cap_sock_setsockopt_old Andre Guedes
2012-05-31 20:01 ` [PATCH v2 3/3] Bluetooth: Rename L2CAP_LE_DEFAULT_MTU Andre Guedes
2012-05-31 20:55 ` Gustavo Padovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).