* [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new()
@ 2014-11-26 8:45 Jakub Tyszkowski
2014-11-26 8:45 ` [PATCH 2/2] gattrib: Fix not changing the buffer size when mtu is reduced Jakub Tyszkowski
2014-12-01 12:04 ` [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Szymon Janc
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Tyszkowski @ 2014-11-26 8:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
We were setting only the buffer in gattrib but att was left with the
default value of 23 (LE transport layer defaults). For BREDR transport
layer this may result in using smaller MTU than the minimum allowed (48).
This was affecting cases when MTU Exchange was not supported by the
remote device and defaults were used.
---
attrib/gattrib.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ce7f7b3..a04a0ee 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -83,6 +83,9 @@ GAttrib *g_attrib_new(GIOChannel *io, guint16 mtu)
if (!attr->att)
goto fail;
+ if (!bt_att_set_mtu(attr->att, mtu))
+ goto fail;
+
attr->buf = malloc0(mtu);
attr->buflen = mtu;
if (!attr->buf)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] gattrib: Fix not changing the buffer size when mtu is reduced
2014-11-26 8:45 [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Jakub Tyszkowski
@ 2014-11-26 8:45 ` Jakub Tyszkowski
2014-12-01 12:04 ` [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Szymon Janc
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Tyszkowski @ 2014-11-26 8:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
Using larger buffer than mtu resulted in not sending the message at all
as encode_pdu() in shared/att.c fails when provided data buffer is larger
than current mtu.
---
attrib/gattrib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index a04a0ee..f20b4f9 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -325,7 +325,7 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
{
/* Clients of this expect a buffer to use. */
- if (mtu > attrib->buflen) {
+ if (mtu != attrib->buflen) {
attrib->buf = g_realloc(attrib->buf, mtu);
attrib->buflen = mtu;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new()
2014-11-26 8:45 [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Jakub Tyszkowski
2014-11-26 8:45 ` [PATCH 2/2] gattrib: Fix not changing the buffer size when mtu is reduced Jakub Tyszkowski
@ 2014-12-01 12:04 ` Szymon Janc
1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-12-01 12:04 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth
Hi Jakub,
On Wednesday 26 of November 2014 09:45:50 Jakub Tyszkowski wrote:
> We were setting only the buffer in gattrib but att was left with the
> default value of 23 (LE transport layer defaults). For BREDR transport
> layer this may result in using smaller MTU than the minimum allowed (48).
>
> This was affecting cases when MTU Exchange was not supported by the
> remote device and defaults were used.
> ---
> attrib/gattrib.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/attrib/gattrib.c b/attrib/gattrib.c
> index ce7f7b3..a04a0ee 100644
> --- a/attrib/gattrib.c
> +++ b/attrib/gattrib.c
> @@ -83,6 +83,9 @@ GAttrib *g_attrib_new(GIOChannel *io, guint16 mtu)
> if (!attr->att)
> goto fail;
>
> + if (!bt_att_set_mtu(attr->att, mtu))
> + goto fail;
> +
> attr->buf = malloc0(mtu);
> attr->buflen = mtu;
> if (!attr->buf)
This patch is now applied. thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-01 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 8:45 [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Jakub Tyszkowski
2014-11-26 8:45 ` [PATCH 2/2] gattrib: Fix not changing the buffer size when mtu is reduced Jakub Tyszkowski
2014-12-01 12:04 ` [PATCH 1/2] gattrib: Fix not setting att's mtu size in g_attrib_new() Szymon Janc
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).