* Re: [RFC] Initial avctp test
From: Andrei Emeltchenko @ 2014-01-28 10:36 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZKusSmbTTEVLmU2Xa4+L5dOaKCHt8dFaeT2jP_==uL+jw@mail.gmail.com>
Hi Luiz,
On Mon, Jan 27, 2014 at 10:36:42AM -0800, Luiz Augusto von Dentz wrote:
> Hi Andrei,
>
> On Mon, Jan 27, 2014 at 7:56 AM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > This is initial invalid packet size test, sent as RFC since I am not
> > sure what might be tested for avctp.
> >
> > Andrei Emeltchenko (1):
> > unit/avctp: Add initial AVCTP test setup
> >
> > Makefile.am | 8 ++
> > unit/test-avctp.c | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 270 insertions(+)
> > create mode 100644 unit/test-avctp.c
> >
> > --
> > 1.8.3.2
>
> You should follow the testing spec:
> https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=40404
>
> Please follow the same name convention that is used by the testing
> spec and for now do not introduce any other test that is not part of
> the testing spec.
I have this AVCTP.TS spec but what might be tested for example with test
case "TP/CCM/BV-01-C"?
Even looking at session_cb() for AVCTP there seems to be only packet
length check. In contrast for AVDTP there is command parser so you might
be able to test something.
Shall we test AVRCP instead?
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH v3 0/4] Regression fixes for rfcomm/tty.c
From: Gianluca Anzolin @ 2014-01-28 8:31 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Alexander Holler, Gustavo F. Padovan, peter,
linux-bluetooth@vger.kernel.org development, Greg KH, jslaby,
stable
In-Reply-To: <E0DDC796-EECF-46B6-8EDF-801CF8EFD456@holtmann.org>
On Mon, Jan 20, 2014 at 09:37:14AM -0800, Marcel Holtmann wrote:
> Hi Alexander,
>
> >> all 4 patches have been applied to bluetooth-next tree.
> >
> > Maybe a bit late, but I've just seen they miss a Cc: stable@vger.kernel.org to automatically end up in 3.12 and 3.13 too.
>
> we can always promote them to stable. On Purpose I wanted them to cycle through bluetooth-next for a while to make sure they do not cause any other regressions.
>
> Regards
>
> Marcel
>
Unfortunately it seems I overlooked the fact that rfcomm_dev_activate() is
called with the port->mutex held. So patches 2/3/4 cause a regression I missed
because I didn't turn on the appropriate debug options (circular locking
dependency, a bug report already appeared on this list).
I'm afraid this all stems from my partial knowledge of the tty_port code and
unfortunately I don't know how to solve the problem right now.
I think it's better to revert those patches for the moment.
Regards,
Gianluca
^ permalink raw reply
* [PATCH BlueZ v2 4/4] android/hal-audio: Set stream fd to blocking
From: Luiz Augusto von Dentz @ 2014-01-28 6:17 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390889820-24709-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the stream to block on io operation so it does not return
EAGAIN on syscall such as write.
---
android/hal-audio.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 2ca6289..21c1d94 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -25,6 +25,7 @@
#include <sys/un.h>
#include <unistd.h>
#include <arpa/inet.h>
+#include <fcntl.h>
#include <hardware/audio.h>
#include <hardware/hardware.h>
@@ -1121,7 +1122,7 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
struct audio_preset *preset;
const struct audio_codec *codec;
uint16_t mtu;
- int fd;
+ int fd, flags;
out = calloc(1, sizeof(struct a2dp_stream_out));
if (!out)
@@ -1156,8 +1157,18 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
if (!preset || fd < 0)
goto fail;
- out->ep->fd = fd;
+ flags = fcntl(fd, F_GETFL, 0);
+ if (flags < 0) {
+ error("fcntl(F_GETFL): %s (%d)", strerror(errno), errno);
+ goto fail;
+ }
+ if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) < 0) {
+ error("fcntl(F_SETFL): %s (%d)", strerror(errno), errno);
+ goto fail;
+ }
+
+ out->ep->fd = fd;
codec = out->ep->codec;
codec->init(preset, mtu, &out->ep->codec_data);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ v2 3/4] android/hal-audio: Fix not handling EINTR errors
From: Luiz Augusto von Dentz @ 2014-01-28 6:16 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390889820-24709-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the kernel interrupts us while writting just try again.
---
android/hal-audio.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 8d737ad..2ca6289 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -399,7 +399,7 @@ static void sbc_resume(void *codec_data)
sbc_data->frames_sent = 0;
}
-static void write_media_packet(int fd, struct sbc_data *sbc_data,
+static int write_media_packet(int fd, struct sbc_data *sbc_data,
struct media_packet *mp, size_t data_len)
{
struct timespec cur;
@@ -407,10 +407,13 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
unsigned expected_frames;
int ret;
- ret = write(fd, mp, sizeof(*mp) + data_len);
- if (ret < 0) {
- int err = errno;
- error("SBC: failed to write data: %d (%s)", err, strerror(err));
+ while (true) {
+ ret = write(fd, mp, sizeof(*mp) + data_len);
+ if (ret >= 0)
+ break;
+
+ if (errno != EINTR)
+ return -errno;
}
sbc_data->frames_sent += mp->payload.frame_count;
@@ -432,6 +435,8 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
if (sbc_data->frames_sent >= expected_frames)
usleep(sbc_data->frame_duration *
mp->payload.frame_count);
+
+ return ret;
}
static ssize_t sbc_write_data(void *codec_data, const void *buffer,
@@ -474,7 +479,9 @@ static ssize_t sbc_write_data(void *codec_data, const void *buffer,
*/
if (mp->payload.frame_count == sbc_data->frames_per_packet ||
bytes == consumed) {
- write_media_packet(fd, sbc_data, mp, encoded);
+ ret = write_media_packet(fd, sbc_data, mp, encoded);
+ if (ret < 0)
+ return ret;
encoded = 0;
free_space = sbc_data->out_buf_size - sizeof(*mp);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ v2 2/4] android/AVDTP: Make stream channel priority 5
From: Luiz Augusto von Dentz @ 2014-01-28 6:16 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390889820-24709-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes channel priority 5 so it has higher priority than regular
traffic but less than signalling channel.
---
android/avdtp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/avdtp.c b/android/avdtp.c
index 4cfffc8..23fe519 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2833,10 +2833,19 @@ gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
size_t imtu, size_t omtu)
{
GIOChannel *io;
+ int priority;
if (stream != stream->session->pending_open)
return FALSE;
+ priority = 5;
+ if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &priority,
+ sizeof(priority)) < 0) {
+ error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
+ errno);
+ return FALSE;
+ }
+
io = g_io_channel_unix_new(fd);
handle_transport_connect(stream->session, io, imtu, omtu);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ v2 1/4] android/AVDTP: Make signalling channel priority 6
From: Luiz Augusto von Dentz @ 2014-01-28 6:16 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes signalling priority 6 so it can push commands before the
stream channel, without this the stream channel may be schedule
first and cause the signalling commands to timeout while waiting a slot.
---
v2: Return error if writes fails since that probably means the socket has been
disconnected, also makes code setting socket to blocking a bit cleaner.
android/avdtp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/avdtp.c b/android/avdtp.c
index 4abcd75..4cfffc8 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2057,6 +2057,7 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
struct avdtp *session;
GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
int new_fd;
+ int priority;
new_fd = dup(fd);
if (new_fd < 0) {
@@ -2064,6 +2065,14 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
return NULL;
}
+ priority = 6;
+ if (setsockopt(new_fd, SOL_SOCKET, SO_PRIORITY,
+ (const void *) &priority, sizeof(priority)) < 0) {
+ error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
+ errno);
+ return NULL;
+ }
+
session = g_new0(struct avdtp, 1);
session->io = g_io_channel_unix_new(new_fd);
session->version = version;
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ 4/4] android/hal-audio: Set stream fd to blocking
From: Luiz Augusto von Dentz @ 2014-01-27 23:41 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390866110-16184-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the stream to block on io operation so it does not return
EAGAIN on syscall such as write.
---
android/hal-audio.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 8a0737b..103e174 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -25,6 +25,7 @@
#include <sys/un.h>
#include <unistd.h>
#include <arpa/inet.h>
+#include <fcntl.h>
#include <hardware/audio.h>
#include <hardware/hardware.h>
@@ -1159,8 +1160,13 @@ static int audio_open_output_stream(struct audio_hw_device *dev,
if (!preset || fd < 0)
goto fail;
- out->ep->fd = fd;
+ if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NONBLOCK) < 0) {
+ error("fcntl(F_SETFL, ~O_NONBLOCK): %s (%d)", strerror(errno),
+ errno);
+ goto fail;
+ }
+ out->ep->fd = fd;
codec = out->ep->codec;
codec->init(preset, mtu, &out->ep->codec_data);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ 3/4] android/hal-audio: Fix not handling EINTR errors
From: Luiz Augusto von Dentz @ 2014-01-27 23:41 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390866110-16184-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the kernel interrupts us while writting just try again.
---
android/hal-audio.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 8d737ad..8a0737b 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -399,7 +399,7 @@ static void sbc_resume(void *codec_data)
sbc_data->frames_sent = 0;
}
-static void write_media_packet(int fd, struct sbc_data *sbc_data,
+static int write_media_packet(int fd, struct sbc_data *sbc_data,
struct media_packet *mp, size_t data_len)
{
struct timespec cur;
@@ -407,10 +407,13 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
unsigned expected_frames;
int ret;
- ret = write(fd, mp, sizeof(*mp) + data_len);
- if (ret < 0) {
- int err = errno;
- error("SBC: failed to write data: %d (%s)", err, strerror(err));
+ while (true) {
+ ret = write(fd, mp, sizeof(*mp) + data_len);
+ if (ret >= 0)
+ break;
+
+ if (errno != EINTR)
+ return -errno;
}
sbc_data->frames_sent += mp->payload.frame_count;
@@ -432,6 +435,8 @@ static void write_media_packet(int fd, struct sbc_data *sbc_data,
if (sbc_data->frames_sent >= expected_frames)
usleep(sbc_data->frame_duration *
mp->payload.frame_count);
+
+ return ret;
}
static ssize_t sbc_write_data(void *codec_data, const void *buffer,
@@ -474,7 +479,12 @@ static ssize_t sbc_write_data(void *codec_data, const void *buffer,
*/
if (mp->payload.frame_count == sbc_data->frames_per_packet ||
bytes == consumed) {
- write_media_packet(fd, sbc_data, mp, encoded);
+ ret = write_media_packet(fd, sbc_data, mp, encoded);
+ if (ret < 0) {
+ error("SBC: failed to write data: %d (%s)", ret,
+ strerror(ret));
+ break;
+ }
encoded = 0;
free_space = sbc_data->out_buf_size - sizeof(*mp);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ 2/4] android/AVDTP: Make stream channel priority 5
From: Luiz Augusto von Dentz @ 2014-01-27 23:41 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390866110-16184-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes channel priority 5 so it has higher priority than regular
traffic but less than signalling channel.
---
android/avdtp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/avdtp.c b/android/avdtp.c
index 4cfffc8..23fe519 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2833,10 +2833,19 @@ gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
size_t imtu, size_t omtu)
{
GIOChannel *io;
+ int priority;
if (stream != stream->session->pending_open)
return FALSE;
+ priority = 5;
+ if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &priority,
+ sizeof(priority)) < 0) {
+ error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
+ errno);
+ return FALSE;
+ }
+
io = g_io_channel_unix_new(fd);
handle_transport_connect(stream->session, io, imtu, omtu);
--
1.8.4.2
^ permalink raw reply related
* [PATCH BlueZ 1/4] android/AVDTP: Make signalling channel priority 6
From: Luiz Augusto von Dentz @ 2014-01-27 23:41 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes signalling priority 6 so it can push commands before the
stream channel, without this the stream channel may be schedule
first and cause the signalling commands to timeout while waiting a slot.
---
android/avdtp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/android/avdtp.c b/android/avdtp.c
index 4abcd75..4cfffc8 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2057,6 +2057,7 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
struct avdtp *session;
GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
int new_fd;
+ int priority;
new_fd = dup(fd);
if (new_fd < 0) {
@@ -2064,6 +2065,14 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
return NULL;
}
+ priority = 6;
+ if (setsockopt(new_fd, SOL_SOCKET, SO_PRIORITY,
+ (const void *) &priority, sizeof(priority)) < 0) {
+ error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
+ errno);
+ return NULL;
+ }
+
session = g_new0(struct avdtp, 1);
session->io = g_io_channel_unix_new(new_fd);
session->version = version;
--
1.8.4.2
^ permalink raw reply related
* Re: [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs
From: Marcel Holtmann @ 2014-01-27 23:36 UTC (permalink / raw)
To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1390864295-4259-3-git-send-email-johan.hedberg@gmail.com>
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
* Re: [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation
From: Marcel Holtmann @ 2014-01-27 23:32 UTC (permalink / raw)
To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1390864295-4259-2-git-send-email-johan.hedberg@gmail.com>
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
* Re: [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value
From: Marcel Holtmann @ 2014-01-27 23:30 UTC (permalink / raw)
To: Johan Hedberg; +Cc: BlueZ development
In-Reply-To: <1390864295-4259-1-git-send-email-johan.hedberg@gmail.com>
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
* [PATCH 3/3] Bluetooth: Fix disconnecting L2CAP when a credits overflow occurs
From: johan.hedberg @ 2014-01-27 23:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390864295-4259-1-git-send-email-johan.hedberg@gmail.com>
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
* [PATCH 2/3] Bluetooth: Fix disconnecting L2CAP channel for credits violation
From: johan.hedberg @ 2014-01-27 23:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1390864295-4259-1-git-send-email-johan.hedberg@gmail.com>
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
* [PATCH 1/3] Bluetooth: Fix respecting le_default_mps value
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
* Re: [PATCH BlueZ 4/4] emulator: Fix crash if socket(AF_ALG) is not supported by the kernel
From: Szymon Janc @ 2014-01-27 20:52 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: BlueZ development
In-Reply-To: <CAJdJm_MHvakZpy_j_X3ACOS9EegKyO8WKL45w5u4t_h2LOBXww@mail.gmail.com>
Hi,
On Monday 27 of January 2014 16:03:59 Anderson Lizardo wrote:
> Hi Johan,
>
> On Mon, Jan 27, 2014 at 1:59 PM, Johan Hedberg <johan.hedberg@gmail.com>
wrote:
> > This patch has been applied. Thanks.
>
> Any comments on the other patches that touch android/* files?
Applied as well, thanks.
--
BR
Szymon Janc
^ permalink raw reply
* Re: [RFC BlueZ] android/AVDTP: Make signalling channel high priority
From: Luiz Augusto von Dentz @ 2014-01-27 20:44 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ development
In-Reply-To: <7AF5DE79-4CEA-453C-895C-EF03DE9205B8@holtmann.org>
Hi Marcel,
On Mon, Jan 27, 2014 at 12:40 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Luiz,
>
>> This makes signalling high priority (6) so it can push commands before
>> the stream channel, without this the stream channel may be schedule
>> first and cause the signalling commands to timeout while waiting a slot.
>> ---
>> android/avdtp.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/android/avdtp.c b/android/avdtp.c
>> index 4abcd75..4cfffc8 100644
>> --- a/android/avdtp.c
>> +++ b/android/avdtp.c
>> @@ -2057,6 +2057,7 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
>> struct avdtp *session;
>> GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
>> int new_fd;
>> + int priority;
>>
>> new_fd = dup(fd);
>> if (new_fd < 0) {
>> @@ -2064,6 +2065,14 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
>> return NULL;
>> }
>>
>> + priority = 6;
>> + if (setsockopt(new_fd, SOL_SOCKET, SO_PRIORITY,
>> + (const void *) &priority, sizeof(priority)) < 0) {
>> + error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
>> + errno);
>> + return NULL;
>> + }
>> +
>
> I think we should make it one higher than the media channel. If we are currently using priority 6 on the media channel than this should be 7. If 7 is not possible, then we might degrade the media channel to 5.
Setting anything bigger than 6 requires CAP_NET_ADMIN so it would
requires unit tests to run with it, perhaps we can do some logic that
checks if we can over 6 or not depending on what capabilities we have.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC BlueZ] android/AVDTP: Make signalling channel high priority
From: Marcel Holtmann @ 2014-01-27 20:40 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: BlueZ development
In-Reply-To: <1390854261-5325-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
> This makes signalling high priority (6) so it can push commands before
> the stream channel, without this the stream channel may be schedule
> first and cause the signalling commands to timeout while waiting a slot.
> ---
> android/avdtp.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/android/avdtp.c b/android/avdtp.c
> index 4abcd75..4cfffc8 100644
> --- a/android/avdtp.c
> +++ b/android/avdtp.c
> @@ -2057,6 +2057,7 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
> struct avdtp *session;
> GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
> int new_fd;
> + int priority;
>
> new_fd = dup(fd);
> if (new_fd < 0) {
> @@ -2064,6 +2065,14 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
> return NULL;
> }
>
> + priority = 6;
> + if (setsockopt(new_fd, SOL_SOCKET, SO_PRIORITY,
> + (const void *) &priority, sizeof(priority)) < 0) {
> + error("setsockopt(SO_PRIORITY): %s (%d)", strerror(errno),
> + errno);
> + return NULL;
> + }
> +
I think we should make it one higher than the media channel. If we are currently using priority 6 on the media channel than this should be 7. If 7 is not possible, then we might degrade the media channel to 5.
Regards
Marcel
^ permalink raw reply
* [PATCH BlueZ v5 18/18] bluetooth.conf: Add ObjectManager interface
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
---
src/bluetooth.conf | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 0495200..ad8891a 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -18,6 +18,7 @@
<allow send_interface="org.bluez.Profile1"/>
<allow send_interface="org.bluez.HeartRateWatcher1"/>
<allow send_interface="org.bluez.CyclingSpeedWatcher1"/>
+ <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
</policy>
<policy at_console="true">
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ v5 17/18] gatttool: Add unix socket support for interactive mode
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
This patch allows running GATT operations over unix socket on
interactive mode.
---
attrib/interactive.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 70c091c..67e060e 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -84,7 +84,7 @@ static char *get_prompt(void)
if (opt_dst)
g_string_append_printf(prompt, "[%17s]", opt_dst);
else
- g_string_append_printf(prompt, "[%17s]", "");
+ g_string_append_printf(prompt, "[LOCAL]");
if (conn_state == STATE_CONNECTED)
g_string_append(prompt, COLOR_OFF);
@@ -405,15 +405,18 @@ static void cmd_connect(int argcp, char **argvp)
opt_dst_type = g_strdup("public");
}
- if (opt_dst == NULL) {
- error("Remote Bluetooth address required\n");
- return;
+ if (opt_dst) {
+
+ rl_printf("Attempting to connect to %s\n", opt_dst);
+ set_state(STATE_CONNECTING);
+ iochannel = gatt_connect(opt_src, opt_dst, opt_dst_type,
+ opt_sec_level, opt_psm, opt_mtu,
+ connect_cb, &gerr);
+ } else {
+ rl_printf("Local connection\n");
+ iochannel = unix_connect(connect_cb, &gerr);
}
- rl_printf("Attempting to connect to %s\n", opt_dst);
- set_state(STATE_CONNECTING);
- iochannel = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level,
- opt_psm, opt_mtu, connect_cb, &gerr);
if (iochannel == NULL) {
set_state(STATE_DISCONNECTED);
error("%s\n", gerr->message);
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ v5 16/18] gatttool: Add unix socket connect
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds the initial support for GATT procedures over unix
socket transport on command line mode (one-shot command). Temporary
solution to allow local GATT procedures testing.
---
attrib/gatttool.c | 27 ++++++++++++++++++++-------
attrib/gatttool.h | 1 +
attrib/utils.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 7 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 9f2ead9..cf106de 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -29,7 +29,6 @@
#include <errno.h>
#include <glib.h>
#include <stdlib.h>
-#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -53,6 +52,7 @@ static int opt_end = 0xffff;
static int opt_handle = -1;
static int opt_mtu = 0;
static int opt_psm = 0;
+static gboolean opt_local = FALSE;
static gboolean opt_primary = FALSE;
static gboolean opt_characteristics = FALSE;
static gboolean opt_char_read = FALSE;
@@ -511,6 +511,8 @@ static GOptionEntry options[] = {
"Specify local adapter interface", "hciX" },
{ "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst,
"Specify remote Bluetooth address", "MAC" },
+ { "local", 'L', 0, G_OPTION_ARG_NONE, &opt_local,
+ "Use unix socket transport (local communication)", NULL },
{ "addr-type", 't', 0, G_OPTION_ARG_STRING, &opt_dst_type,
"Set LE address type. Default: public", "[public | random]"},
{ "mtu", 'm', 0, G_OPTION_ARG_INT, &opt_mtu,
@@ -563,6 +565,11 @@ int main(int argc, char *argv[])
g_clear_error(&gerr);
}
+ if (opt_local) {
+ opt_src = NULL;
+ opt_dst = NULL;
+ }
+
if (opt_interactive) {
interactive(opt_src, opt_dst, opt_dst_type, opt_psm);
goto done;
@@ -588,14 +595,20 @@ int main(int argc, char *argv[])
goto done;
}
- if (opt_dst == NULL) {
- g_print("Remote Bluetooth address required\n");
- got_error = TRUE;
- goto done;
+ if (opt_local)
+ chan = unix_connect(connect_cb, &gerr);
+ else {
+ if (opt_dst == NULL) {
+ g_print("Remote Bluetooth address required\n");
+ got_error = TRUE;
+ goto done;
+ }
+
+ chan = gatt_connect(opt_src, opt_dst, opt_dst_type,
+ opt_sec_level, opt_psm, opt_mtu,
+ connect_cb, &gerr);
}
- chan = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level,
- opt_psm, opt_mtu, connect_cb, &gerr);
if (chan == NULL) {
g_printerr("%s\n", gerr->message);
g_clear_error(&gerr);
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 8f0913c..be8e236 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -27,4 +27,5 @@ GIOChannel *gatt_connect(const char *src, const char *dst,
const char *dst_type, const char *sec_level,
int psm, int mtu, BtIOConnect connect_cb,
GError **gerr);
+GIOChannel *unix_connect(BtIOConnect connect_cb, GError **gerr);
size_t gatt_attr_data_from_string(const char *str, uint8_t **data);
diff --git a/attrib/utils.c b/attrib/utils.c
index 17f02be..7d2966f 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -25,7 +25,12 @@
#include "config.h"
#endif
+#include <errno.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
#include <glib.h>
#include <bluetooth/bluetooth.h>
@@ -101,6 +106,55 @@ GIOChannel *gatt_connect(const char *src, const char *dst,
return chan;
}
+static gboolean unix_connect_cb(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ BtIOConnect connect_cb = user_data;
+ GError *gerr;
+
+ if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+ gerr = g_error_new_literal(G_IO_CHANNEL_ERROR,
+ G_IO_CHANNEL_ERROR_FAILED,
+ "connection attempt failed");
+ connect_cb(io, gerr, user_data);
+ g_clear_error(&gerr);
+ } else {
+ connect_cb(io, NULL, user_data);
+ }
+
+ return FALSE;
+}
+
+GIOChannel *unix_connect(BtIOConnect connect_cb, GError **gerr)
+{
+ GIOChannel *io;
+ struct sockaddr_un uaddr = {
+ .sun_family = AF_UNIX,
+ .sun_path = "\0/bluetooth/unix_att",
+ };
+ int sk;
+
+ sk = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC , 0);
+ if (sk < 0) {
+ g_set_error_literal(gerr, G_IO_CHANNEL_ERROR,
+ G_IO_CHANNEL_ERROR_FAILED, strerror(errno));
+ return NULL;
+ }
+
+ if (connect(sk, (struct sockaddr *) &uaddr, sizeof(uaddr)) < 0) {
+ g_set_error_literal(gerr, G_IO_CHANNEL_ERROR,
+ G_IO_CHANNEL_ERROR_FAILED, strerror(errno));
+ close(sk);
+ return NULL;
+ }
+
+ io = g_io_channel_unix_new(sk);
+ g_io_add_watch(io, G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ unix_connect_cb, connect_cb);
+
+ return io;
+}
+
size_t gatt_attr_data_from_string(const char *str, uint8_t **data)
{
char tmp[3];
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ v5 15/18] test: Add registering external service
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
This patch extends gatt-service to call RegisterService() when org.bluez
service gets connected to the system bus.
---
test/gatt-service.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/test/gatt-service.c b/test/gatt-service.c
index 4059336..b656ef3 100644
--- a/test/gatt-service.c
+++ b/test/gatt-service.c
@@ -35,6 +35,7 @@
#include <dbus/dbus.h>
#include <gdbus/gdbus.h>
+#define GATT_MGR_IFACE "org.bluez.GattManager1"
#define SERVICE_IFACE "org.bluez.GattService1"
/* Immediate Alert Service UUID */
@@ -100,6 +101,65 @@ static void create_services(DBusConnection *conn)
printf("Registered service: %s\n", service_path);
}
+static void register_external_service_reply(DBusPendingCall *call,
+ void *user_data)
+{
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ DBusError derr;
+
+ dbus_error_init(&derr);
+ dbus_set_error_from_message(&derr, reply);
+
+ if (dbus_error_is_set(&derr))
+ printf("RegisterService: %s\n", derr.message);
+ else
+ printf("RegisterService: OK\n");
+
+ dbus_message_unref(reply);
+ dbus_error_free(&derr);
+}
+
+static void register_external_service(gpointer a, gpointer b)
+{
+ DBusConnection *conn = b;
+ const char *path = a;
+ DBusMessage *msg;
+ DBusPendingCall *call;
+ DBusMessageIter iter, dict;
+
+ msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
+ GATT_MGR_IFACE, "RegisterService");
+ if (msg == NULL) {
+ printf("Couldn't allocate D-Bus message\n");
+ return;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
+
+ /* TODO: Add options dictionary */
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
+ dbus_message_unref(msg);
+ return;
+ }
+
+ dbus_pending_call_set_notify(call, register_external_service_reply,
+ NULL, NULL);
+
+ dbus_pending_call_unref(call);
+}
+
+static void connect_handler(DBusConnection *conn, void *user_data)
+{
+ g_slist_foreach(services, register_external_service, conn);
+}
+
static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
gpointer user_data)
{
@@ -171,6 +231,7 @@ static guint setup_signalfd(void)
int main(int argc, char *argv[])
{
+ GDBusClient *client;
DBusConnection *dbus_conn;
guint signal;
@@ -189,8 +250,14 @@ int main(int argc, char *argv[])
create_services(dbus_conn);
+ client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez");
+
+ g_dbus_client_set_connect_watch(client, connect_handler, NULL);
+
g_main_loop_run(main_loop);
+ g_dbus_client_unref(client);
+
g_source_remove(signal);
g_slist_free_full(services, g_free);
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ v5 14/18] test: Add signal handling for gatt-service
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
This patch implements signal handling to run cleanup tasks before
exiting.
---
test/gatt-service.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/test/gatt-service.c b/test/gatt-service.c
index 769fd37..4059336 100644
--- a/test/gatt-service.c
+++ b/test/gatt-service.c
@@ -27,6 +27,9 @@
#include <errno.h>
#include <stdio.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <sys/signalfd.h>
#include <glib.h>
#include <dbus/dbus.h>
@@ -97,9 +100,83 @@ static void create_services(DBusConnection *conn)
printf("Registered service: %s\n", service_path);
}
+static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
+ gpointer user_data)
+{
+ static bool __terminated = false;
+ struct signalfd_siginfo si;
+ ssize_t result;
+ int fd;
+
+ if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+ return FALSE;
+
+ fd = g_io_channel_unix_get_fd(channel);
+
+ result = read(fd, &si, sizeof(si));
+ if (result != sizeof(si))
+ return FALSE;
+
+ switch (si.ssi_signo) {
+ case SIGINT:
+ case SIGTERM:
+ if (!__terminated) {
+ printf("Terminating\n");
+ g_main_loop_quit(main_loop);
+ }
+
+ __terminated = true;
+ break;
+ }
+
+ return TRUE;
+}
+
+static guint setup_signalfd(void)
+{
+ GIOChannel *channel;
+ guint source;
+ sigset_t mask;
+ int fd;
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGINT);
+ sigaddset(&mask, SIGTERM);
+
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
+ perror("Failed to set signal mask");
+ return 0;
+ }
+
+ fd = signalfd(-1, &mask, 0);
+ if (fd < 0) {
+ perror("Failed to create signal descriptor");
+ return 0;
+ }
+
+ channel = g_io_channel_unix_new(fd);
+
+ g_io_channel_set_close_on_unref(channel, TRUE);
+ g_io_channel_set_encoding(channel, NULL, NULL);
+ g_io_channel_set_buffered(channel, FALSE);
+
+ source = g_io_add_watch(channel,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ signal_handler, NULL);
+
+ g_io_channel_unref(channel);
+
+ return source;
+}
+
int main(int argc, char *argv[])
{
DBusConnection *dbus_conn;
+ guint signal;
+
+ signal = setup_signalfd();
+ if (signal == 0)
+ return -errno;
dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
@@ -114,6 +191,8 @@ int main(int argc, char *argv[])
g_main_loop_run(main_loop);
+ g_source_remove(signal);
+
g_slist_free_full(services, g_free);
dbus_connection_unref(dbus_conn);
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ v5 13/18] gitignore: Add test/gatt-service
From: Claudio Takahasi @ 2014-01-27 20:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390854924-31904-1-git-send-email-claudio.takahasi@openbossa.org>
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index e2b23fc..5e5880f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -75,6 +75,7 @@ test/sap_client.pyc
test/bluezutils.pyc
unit/test-ringbuf
unit/test-queue
+test/gatt-service
unit/test-eir
unit/test-uuid
unit/test-crc
--
1.8.3.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox