* [PATCH BlueZ 10/10] unit: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
unit/test-uuid.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/unit/test-uuid.c b/unit/test-uuid.c
index cbccc82..79ab3e6 100644
--- a/unit/test-uuid.c
+++ b/unit/test-uuid.c
@@ -28,7 +28,8 @@
#include <glib.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
+
+#include "lib/uuid.h"
struct uuid_test_data {
const char *str;
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 09/10] attrib: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
attrib/att.c | 2 +-
attrib/gatt-service.c | 2 +-
attrib/gatt.c | 2 +-
attrib/gattrib.c | 4 ++--
attrib/gatttool.c | 2 +-
attrib/interactive.c | 3 +--
attrib/utils.c | 2 +-
7 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/attrib/att.c b/attrib/att.c
index de11811..b26273e 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -31,10 +31,10 @@
#include <stdlib.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
#include <glib.h>
+#include "lib/uuid.h"
#include "att.h"
const char *att_ecode2str(uint8_t status)
diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index e8788d9..bdb12cd 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
@@ -27,10 +27,10 @@
#endif
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <bluetooth/sdp.h>
#include <adapter.h>
+#include "lib/uuid.h"
#include "gattrib.h"
#include "att.h"
#include "gatt.h"
diff --git a/attrib/gatt.c b/attrib/gatt.c
index 38c050e..d54feac 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -29,10 +29,10 @@
#include <stdint.h>
#include <stdlib.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
+#include "lib/uuid.h"
#include "att.h"
#include "gattrib.h"
#include "gatt.h"
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index bf40532..58f19d0 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -33,9 +33,9 @@
#include <stdio.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
-
#include <btio/btio.h>
+
+#include "lib/uuid.h"
#include "log.h"
#include "att.h"
#include "gattrib.h"
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index e66059d..29e3261 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -34,8 +34,8 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
-#include <bluetooth/uuid.h>
+#include "lib/uuid.h"
#include "att.h"
#include <btio/btio.h>
#include "gattrib.h"
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 51f620a..a99ad0a 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -31,11 +31,10 @@
#include <stdio.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
-
#include <readline/readline.h>
#include <readline/history.h>
+#include "lib/uuid.h"
#include <btio/btio.h>
#include "att.h"
#include "gattrib.h"
diff --git a/attrib/utils.c b/attrib/utils.c
index 43244c2..f9813d1 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -31,9 +31,9 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
-#include <bluetooth/uuid.h>
#include <bluetooth/sdp.h>
+#include "lib/uuid.h"
#include <btio/btio.h>
#include "att.h"
#include "gattrib.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 08/10] proximity: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/proximity/immalert.c | 2 +-
profiles/proximity/linkloss.c | 2 +-
profiles/proximity/monitor.c | 2 +-
profiles/proximity/reporter.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/profiles/proximity/immalert.c b/profiles/proximity/immalert.c
index 04557b4..06e8eb8 100644
--- a/profiles/proximity/immalert.c
+++ b/profiles/proximity/immalert.c
@@ -27,12 +27,12 @@
#include <stdbool.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <adapter.h>
#include <dbus/dbus.h>
#include <gdbus/gdbus.h>
+#include "lib/uuid.h"
#include "log.h"
#include "attrib/gattrib.h"
#include "attrib/att.h"
diff --git a/profiles/proximity/linkloss.c b/profiles/proximity/linkloss.c
index c1c4177..cb87b12 100644
--- a/profiles/proximity/linkloss.c
+++ b/profiles/proximity/linkloss.c
@@ -27,12 +27,12 @@
#include <stdbool.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <adapter.h>
#include <dbus/dbus.h>
#include <gdbus/gdbus.h>
+#include "lib/uuid.h"
#include "log.h"
#include "attrib/att-database.h"
#include "attrib/gattrib.h"
diff --git a/profiles/proximity/monitor.c b/profiles/proximity/monitor.c
index e502605..37b02e1 100644
--- a/profiles/proximity/monitor.c
+++ b/profiles/proximity/monitor.c
@@ -36,8 +36,8 @@
#include <sys/stat.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
+#include "lib/uuid.h"
#include "dbus-common.h"
#include "adapter.h"
#include "device.h"
diff --git a/profiles/proximity/reporter.c b/profiles/proximity/reporter.c
index ef3ab6a..31c33ef 100644
--- a/profiles/proximity/reporter.c
+++ b/profiles/proximity/reporter.c
@@ -30,7 +30,6 @@
#include <errno.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <adapter.h>
#include <dbus/dbus.h>
@@ -38,6 +37,7 @@
#include "log.h"
+#include "lib/uuid.h"
#include "dbus-common.h"
#include "error.h"
#include "device.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 07/10] time: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/time/server.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/profiles/time/server.c b/profiles/time/server.c
index ab9fbb4..518a29f 100644
--- a/profiles/time/server.c
+++ b/profiles/time/server.c
@@ -31,13 +31,12 @@
#include <errno.h>
#include <stdbool.h>
-#include <bluetooth/uuid.h>
-
#include <adapter.h>
#include <device.h>
#include <profile.h>
#include <plugin.h>
+#include "lib/uuid.h"
#include "attrib/gattrib.h"
#include "attrib/att.h"
#include "attrib/gatt.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 06/10] alert: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/alert/server.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 3736a0b..4536c81 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -30,9 +30,9 @@
#include <errno.h>
#include <gdbus/gdbus.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <stdlib.h>
+#include "lib/uuid.h"
#include "plugin.h"
#include "dbus-common.h"
#include "attrib/att.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 05/10] scanparam: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/scanparam/scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c
index 7c21ac3..268bdc8 100644
--- a/profiles/scanparam/scan.c
+++ b/profiles/scanparam/scan.c
@@ -30,8 +30,8 @@
#include <errno.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
+#include "lib/uuid.h"
#include "log.h"
#include "plugin.h"
#include "adapter.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 04/10] gatt: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/gatt/gas.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index b5e0e52..429850b 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -32,9 +32,9 @@
#include <errno.h>
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <btio/btio.h>
+#include "lib/uuid.h"
#include "adapter.h"
#include "device.h"
#include "attrib/att.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 03/10] input: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
profiles/input/hog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 7f13abc..7f7bfd2 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -37,12 +37,12 @@
#include "uhid_copy.h"
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
#include <glib.h>
#include "log.h"
+#include "lib/uuid.h"
#include "src/adapter.h"
#include "src/device.h"
#include "src/profile.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 02/10] plugins: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
These headers are not public anymore, so need to use "lib/uuid.h".
---
plugins/gatt-example.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index de090e9..bd0fbff 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -27,10 +27,10 @@
#endif
#include <glib.h>
-#include <bluetooth/uuid.h>
#include <errno.h>
#include <adapter.h>
+#include "lib/uuid.h"
#include "plugin.h"
#include "hcid.h"
#include "log.h"
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 01/10] core: Fix remaining references to bluetooth/uuid.h
From: Anderson Lizardo @ 2013-01-10 13:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
These headers are not public anymore, so need to use "lib/uuid.h".
---
src/attrib-server.c | 2 +-
src/main.c | 2 +-
src/storage.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 0a56942..b2360c3 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -35,10 +35,10 @@
#include <sys/file.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
+#include "lib/uuid.h"
#include <gdbus/gdbus.h>
#include "log.h"
#include <btio/btio.h>
diff --git a/src/main.c b/src/main.c
index bd1e9d9..b9fd369 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,7 +38,6 @@
#include <sys/stat.h>
#include <bluetooth/bluetooth.h>
-#include <bluetooth/uuid.h>
#include <glib.h>
@@ -48,6 +47,7 @@
#include "log.h"
+#include "lib/uuid.h"
#include "hcid.h"
#include "sdpd.h"
#include "adapter.h"
diff --git a/src/storage.c b/src/storage.c
index 8b634ba..f7e4db6 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -41,8 +41,8 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
-#include <bluetooth/uuid.h>
+#include "lib/uuid.h"
#include "textfile.h"
#include "glib-helper.h"
#include "storage.h"
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH BlueZ 01/10] core: Fix remaining references to bluetooth/uuid.h
From: Johan Hedberg @ 2013-01-10 13:13 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1357823709-8627-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Thu, Jan 10, 2013, Anderson Lizardo wrote:
> These headers are not public anymore, so need to use "lib/uuid.h".
> ---
> src/attrib-server.c | 2 +-
> src/main.c | 2 +-
> src/storage.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH -v2] Bluetooth: Fix uuid output in debugfs
From: Johan Hedberg @ 2013-01-10 12:55 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1357805189-2029-1-git-send-email-gustavo@padovan.org>
Hi Gustavo,
On Thu, Jan 10, 2013, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> The uuid should be printed in the CPU endianness and not in little-endian.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> net/bluetooth/hci_sysfs.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Johan
^ permalink raw reply
* [PATCH 5/8 v2] Bluetooth: Fix returning proper command status for start_discovery
From: Johan Hedberg @ 2013-01-10 12:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1357738180-4128-6-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
Management commands should whenever possible fail with proper command
status or command complete events. This patch fixes the
mgmt_start_discovery command to do this for the failure cases where an
incorrect parameter value was passed to it ("not supported" if the
parameter value was valid but the controller doesn't support it and
"invalid params" if it isn't valid at all).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
v2: Use proposed logic for testing for not supported parameters
net/bluetooth/mgmt.c | 46 ++++++++++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 6cff286..37add53 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2383,31 +2383,45 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
switch (hdev->discovery.type) {
case DISCOV_TYPE_BREDR:
- if (lmp_bredr_capable(hdev))
- err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
- else
- err = -ENOTSUPP;
+ if (!lmp_bredr_capable(hdev)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_NOT_SUPPORTED);
+ mgmt_pending_remove(cmd);
+ goto failed;
+ }
+
+ err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
break;
case DISCOV_TYPE_LE:
- if (lmp_host_le_capable(hdev))
- err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
- LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
- else
- err = -ENOTSUPP;
+ if (!lmp_host_le_capable(hdev)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_NOT_SUPPORTED);
+ mgmt_pending_remove(cmd);
+ goto failed;
+ }
+
+ err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
+ LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
break;
case DISCOV_TYPE_INTERLEAVED:
- if (lmp_host_le_capable(hdev) && lmp_bredr_capable(hdev))
- err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
- LE_SCAN_WIN,
- LE_SCAN_TIMEOUT_BREDR_LE);
- else
- err = -ENOTSUPP;
+ if (!lmp_host_le_capable(hdev) || !lmp_bredr_capable(hdev)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_NOT_SUPPORTED);
+ mgmt_pending_remove(cmd);
+ goto failed;
+ }
+
+ err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, LE_SCAN_WIN,
+ LE_SCAN_TIMEOUT_BREDR_LE);
break;
default:
- err = -EINVAL;
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_INVALID_PARAMS);
+ mgmt_pending_remove(cmd);
+ goto failed;
}
if (err < 0)
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH v2 BlueZ] unit: Avoid D-Bus calling _exit() during SDP tests
From: Johan Hedberg @ 2013-01-10 12:31 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1357821030-11412-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Thu, Jan 10, 2013, Anderson Lizardo wrote:
> While running tests, the D-Bus library was set to call _exit() when the
> client leaves the bus. This caused the second test to be interrupted
> without providing a PASS/FAIL result. This was confirmed by running
> test-sdp with DBUS_VERBOSE=1.
>
> This commit disables this behavior, which does not exist on BlueZ
> because g_dbus_set_disconnect_function() implicitly does this.
> ---
> unit/test-gdbus-client.c | 3 +++
> 1 file changed, 3 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH v2 BlueZ] unit: Avoid D-Bus calling _exit() during SDP tests
From: Anderson Lizardo @ 2013-01-10 12:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357779808-25513-1-git-send-email-anderson.lizardo@openbossa.org>
While running tests, the D-Bus library was set to call _exit() when the
client leaves the bus. This caused the second test to be interrupted
without providing a PASS/FAIL result. This was confirmed by running
test-sdp with DBUS_VERBOSE=1.
This commit disables this behavior, which does not exist on BlueZ
because g_dbus_set_disconnect_function() implicitly does this.
---
unit/test-gdbus-client.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index aaf8342..34c714e 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -78,6 +78,9 @@ static struct context *create_context(void)
return NULL;
}
+ /* Avoid D-Bus library calling _exit() before next test finishes. */
+ dbus_connection_set_exit_on_disconnect(context->dbus_conn, FALSE);
+
return context;
}
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 8/8] Bluetooth: Fix sending incorrect new_settings for mgmt_set_powered
From: Marcel Holtmann @ 2013-01-10 8:41 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1357738180-4128-9-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> The socket from which a mgmt_set_powered command was received should
> only receive the command response but no new_settings event.
>
> The mgmt_powered() function which is used to handle the situation with
> the HCI_AUTO_OFF flag tries to check for a pending command to know which
> socket to skip the event for, but since the pending command hasn't been
> added this will not happen.
>
> This patch fixes the issue by adding the pending command for the
> HCI_AUTO_OFF case and thereby ensures that mgmt_powered() will skip the
> right socket when sending the new_settings event, but still send the
> proper response to the socket where the command came from.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 7/8 v2] Bluetooth: Fix checking for exact values of boolean mgmt parameters
From: Gustavo Padovan @ 2013-01-10 8:24 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1357740319-5737-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
* Johan Hedberg <johan.hedberg@gmail.com> [2013-01-09 16:05:19 +0200]:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> All mgmt_set_* commands that take a boolean value encoded in the form of
> a byte should only accept the values 0x00 and 0x01. This patch adds the
> necessary checks for this and returns "invalid params" responses if
> anything else is provided as the value.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> v2: Fix s/SET_SSP/SET_LE/ copy-paste issue
>
> net/bluetooth/mgmt.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
All patches but 5 and 8 were applied to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply
* [PATCH -v2] Bluetooth: Fix uuid output in debugfs
From: Gustavo Padovan @ 2013-01-10 8:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The uuid should be printed in the CPU endianness and not in little-endian.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/hci_sysfs.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 55cceee..23b4e24 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -2,6 +2,7 @@
#include <linux/debugfs.h>
#include <linux/module.h>
+#include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -461,19 +462,18 @@ static const struct file_operations blacklist_fops = {
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
{
- __be32 data0, data4;
- __be16 data1, data2, data3, data5;
+ u32 data0, data5;
+ u16 data1, data2, data3, data4;
- memcpy(&data0, &uuid[0], 4);
- memcpy(&data1, &uuid[4], 2);
- memcpy(&data2, &uuid[6], 2);
- memcpy(&data3, &uuid[8], 2);
- memcpy(&data4, &uuid[10], 4);
- memcpy(&data5, &uuid[14], 2);
+ data5 = get_unaligned_le32(uuid);
+ data4 = get_unaligned_le16(uuid + 4);
+ data3 = get_unaligned_le16(uuid + 6);
+ data2 = get_unaligned_le16(uuid + 8);
+ data1 = get_unaligned_le16(uuid + 10);
+ data0 = get_unaligned_le32(uuid + 12);
- seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x\n",
- ntohl(data0), ntohs(data1), ntohs(data2), ntohs(data3),
- ntohl(data4), ntohs(data5));
+ seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
+ data0, data1, data2, data3, data4, data5);
}
static int uuids_show(struct seq_file *f, void *p)
--
1.8.0.2
^ permalink raw reply related
* [PATCH 16/16] Bluetooth: Remove sk member from struct l2cap_chan
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Now that the removal of socket usage from l2cap_core.c is done we can
remove sk from struct l2cap_chan since we do not use it anywhere anymore.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 2 --
net/bluetooth/l2cap_sock.c | 5 ++---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index d3c8f57..e444d55 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -433,8 +433,6 @@ struct l2cap_seq_list {
#define L2CAP_SEQ_LIST_TAIL 0x8000
struct l2cap_chan {
- struct sock *sk;
-
bdaddr_t src;
bdaddr_t dst;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 07ef90c..910c9d7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1101,11 +1101,12 @@ static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state,
static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
unsigned long len, int nb)
{
+ struct sock *sk = chan->data;
struct sk_buff *skb;
int err;
l2cap_chan_unlock(chan);
- skb = bt_skb_send_alloc(chan->sk, len, nb, &err);
+ skb = bt_skb_send_alloc(sk, len, nb, &err);
l2cap_chan_lock(chan);
if (!skb)
@@ -1293,8 +1294,6 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
l2cap_chan_hold(chan);
- chan->sk = sk;
-
l2cap_pi(sk)->chan = chan;
return sk;
--
1.8.0.2
^ permalink raw reply related
* [PATCH 15/16] Bluetooth: Create l2cap->ops->set_shutdown()
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Isolates the code that sets the socket shutdown mask. This is the last
commit to remove the socket usage from l2cap_core.c
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 5 +++++
net/bluetooth/a2mp.c | 1 +
net/bluetooth/l2cap_core.c | 7 +------
net/bluetooth/l2cap_sock.c | 10 ++++++++++
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index cab7773..d3c8f57 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -556,6 +556,7 @@ struct l2cap_ops {
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb);
void (*resume) (struct l2cap_chan *chan);
+ void (*set_shutdown) (struct l2cap_chan *chan);
};
struct l2cap_conn {
@@ -794,6 +795,10 @@ static inline void l2cap_chan_no_resume(struct l2cap_chan *chan)
{
}
+static inline void l2cap_chan_no_set_shutdown(struct l2cap_chan *chan)
+{
+}
+
extern bool disable_ertm;
int l2cap_init_sockets(void);
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 4a542b3..0a2ec84 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -709,6 +709,7 @@ static struct l2cap_ops a2mp_chan_ops = {
.ready = l2cap_chan_no_ready,
.defer = l2cap_chan_no_defer,
.resume = l2cap_chan_no_resume,
+ .set_shutdown = l2cap_chan_no_set_shutdown,
};
static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 72dd394..5104a88 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3973,7 +3973,6 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
struct l2cap_disconn_rsp rsp;
u16 dcid, scid;
struct l2cap_chan *chan;
- struct sock *sk;
scid = __le16_to_cpu(req->scid);
dcid = __le16_to_cpu(req->dcid);
@@ -3990,15 +3989,11 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
l2cap_chan_lock(chan);
- sk = chan->sk;
-
rsp.dcid = cpu_to_le16(chan->scid);
rsp.scid = cpu_to_le16(chan->dcid);
l2cap_send_cmd(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp);
- lock_sock(sk);
- sk->sk_shutdown = SHUTDOWN_MASK;
- release_sock(sk);
+ chan->ops->set_shutdown(chan);
l2cap_chan_hold(chan);
l2cap_chan_del(chan, ECONNRESET);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index e7b3291..07ef90c 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1159,6 +1159,15 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan)
release_sock(sk);
}
+static void l2cap_sock_set_shutdown_cb(struct l2cap_chan *chan)
+{
+ struct sock *sk = chan->data;
+
+ lock_sock(sk);
+ sk->sk_shutdown = SHUTDOWN_MASK;
+ release_sock(sk);
+}
+
static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
@@ -1170,6 +1179,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.defer = l2cap_sock_defer_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
.resume = l2cap_sock_resume_cb,
+ .set_shutdown = l2cap_sock_set_shutdown_cb,
};
static void l2cap_sock_destruct(struct sock *sk)
--
1.8.0.2
^ permalink raw reply related
* [PATCH 14/16] Bluetooth: Create l2cap->ops->resume()
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
resume() will isolate the code the code to get a socket back from the
suspended state when a security elevation happens.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 5 +++++
net/bluetooth/a2mp.c | 1 +
net/bluetooth/l2cap_core.c | 6 +-----
net/bluetooth/l2cap_sock.c | 13 +++++++++++++
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 574b3ae..cab7773 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -555,6 +555,7 @@ struct l2cap_ops {
void (*defer) (struct l2cap_chan *chan);
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb);
+ void (*resume) (struct l2cap_chan *chan);
};
struct l2cap_conn {
@@ -789,6 +790,10 @@ static inline void l2cap_chan_no_defer(struct l2cap_chan *chan)
{
}
+static inline void l2cap_chan_no_resume(struct l2cap_chan *chan)
+{
+}
+
extern bool disable_ertm;
int l2cap_init_sockets(void);
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index ad6e42f..4a542b3 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -708,6 +708,7 @@ static struct l2cap_ops a2mp_chan_ops = {
.teardown = l2cap_chan_no_teardown,
.ready = l2cap_chan_no_ready,
.defer = l2cap_chan_no_defer,
+ .resume = l2cap_chan_no_resume,
};
static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index f151775..72dd394 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6315,11 +6315,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
if (!status && (chan->state == BT_CONNECTED ||
chan->state == BT_CONFIG)) {
- struct sock *sk = chan->sk;
-
- clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
- sk->sk_state_change(sk);
-
+ chan->ops->resume(chan);
l2cap_check_encryption(chan, encrypt);
l2cap_chan_unlock(chan);
continue;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 58b4a5d..e7b3291 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1147,6 +1147,18 @@ static void l2cap_sock_defer_cb(struct l2cap_chan *chan)
release_sock(sk);
}
+static void l2cap_sock_resume_cb(struct l2cap_chan *chan)
+{
+ struct sock *sk = chan->data;
+
+ lock_sock(sk);
+
+ clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
+ sk->sk_state_change(sk);
+
+ release_sock(sk);
+}
+
static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
@@ -1157,6 +1169,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.ready = l2cap_sock_ready_cb,
.defer = l2cap_sock_defer_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
+ .resume = l2cap_sock_resume_cb,
};
static void l2cap_sock_destruct(struct sock *sk)
--
1.8.0.2
^ permalink raw reply related
* [PATCH 13/16] Bluetooth: Move l2cap_wait_ack() to l2cap_sock.c
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The wait_ack code has a heavy dependency on the socket data structures
and, as of now, it won't be worthless change it to use non-socket
structures as the only user of such feature is a socket.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 3 ++-
net/bluetooth/l2cap_core.c | 32 --------------------------------
net/bluetooth/l2cap_sock.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 6986140..574b3ae 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -757,6 +757,8 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
+#define __missing_ack(c) (c->unacked_frames > 0 && c->conn)
+
static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
{
if (seq1 >= seq2)
@@ -793,7 +795,6 @@ int l2cap_init_sockets(void);
void l2cap_cleanup_sockets(void);
void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
-int __l2cap_wait_ack(struct sock *sk);
int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 935534c..f151775 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1706,38 +1706,6 @@ done:
return err;
}
-int __l2cap_wait_ack(struct sock *sk)
-{
- struct l2cap_chan *chan = l2cap_pi(sk)->chan;
- DECLARE_WAITQUEUE(wait, current);
- int err = 0;
- int timeo = HZ/5;
-
- add_wait_queue(sk_sleep(sk), &wait);
- set_current_state(TASK_INTERRUPTIBLE);
- while (chan->unacked_frames > 0 && chan->conn) {
- if (!timeo)
- timeo = HZ/5;
-
- if (signal_pending(current)) {
- err = sock_intr_errno(timeo);
- break;
- }
-
- release_sock(sk);
- timeo = schedule_timeout(timeo);
- lock_sock(sk);
- set_current_state(TASK_INTERRUPTIBLE);
-
- err = sock_error(sk);
- if (err)
- break;
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(sk_sleep(sk), &wait);
- return err;
-}
-
static void l2cap_monitor_timeout(struct work_struct *work)
{
struct l2cap_chan *chan = container_of(work, struct l2cap_chan,
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3d76de8..58b4a5d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -853,6 +853,38 @@ static void l2cap_sock_kill(struct sock *sk)
sock_put(sk);
}
+static int __l2cap_wait_ack(struct sock *sk)
+{
+ struct l2cap_chan *chan = l2cap_pi(sk)->chan;
+ DECLARE_WAITQUEUE(wait, current);
+ int err = 0;
+ int timeo = HZ/5;
+
+ add_wait_queue(sk_sleep(sk), &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+ while (__missing_ack(chan)) {
+ if (!timeo)
+ timeo = HZ/5;
+
+ if (signal_pending(current)) {
+ err = sock_intr_errno(timeo);
+ break;
+ }
+
+ release_sock(sk);
+ timeo = schedule_timeout(timeo);
+ lock_sock(sk);
+ set_current_state(TASK_INTERRUPTIBLE);
+
+ err = sock_error(sk);
+ if (err)
+ break;
+ }
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(sk_sleep(sk), &wait);
+ return err;
+}
+
static int l2cap_sock_shutdown(struct socket *sock, int how)
{
struct sock *sk = sock->sk;
--
1.8.0.2
^ permalink raw reply related
* [PATCH 12/16] Bluetooth: Use abstract chan->data in comparison
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
If the L2CAP user is l2cap_sock.c chan->data is a pointer to the l2cap
socket so chan->sk and chan->data are the same thing. Then we can just
compare with chan->data instead.
Non-socket users will have skb->sk = NULL, thus this change does not
interfere in other users.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 0c76c55..6986140 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -536,7 +536,7 @@ struct l2cap_chan {
struct list_head list;
struct list_head global_l;
- void *data;
+ void *data; /* l2cap user data. eg: sk for sockets */
struct l2cap_ops *ops;
struct mutex lock;
};
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6d62bfb..935534c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2677,12 +2677,11 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
mutex_lock(&conn->chan_lock);
list_for_each_entry(chan, &conn->chan_l, list) {
- struct sock *sk = chan->sk;
if (chan->chan_type != L2CAP_CHAN_RAW)
continue;
/* Don't send frame to the socket it came from */
- if (skb->sk == sk)
+ if (skb->sk && skb->sk == chan->data)
continue;
nskb = skb_clone(skb, GFP_KERNEL);
if (!nskb)
--
1.8.0.2
^ permalink raw reply related
* [PATCH 11/16] Bluetooth: remove parent socket usage from l2cap_core.c
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Since we do not touch the parent sock in l2cap_core.c anymore we don't
need to lock it there anymore. That lock was replaced by the
l2cap_chan_lock and inside the new_connection() call for l2cap_sock.c the
parent lock is locked, so the operations that uses it can be performed
safely.
The l2cap_chan_lock give us the needed protection to handle the incoming
connections.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 16 ++++------------
net/bluetooth/l2cap_sock.c | 4 ++++
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2c4458a..6d62bfb 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1315,7 +1315,6 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
static void l2cap_le_conn_ready(struct l2cap_conn *conn)
{
- struct sock *parent;
struct l2cap_chan *chan, *pchan;
BT_DBG("");
@@ -1326,9 +1325,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
if (!pchan)
return;
- parent = pchan->sk;
-
- lock_sock(parent);
+ l2cap_chan_lock(pchan);
chan = pchan->ops->new_connection(pchan);
if (!chan)
@@ -1345,7 +1342,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
l2cap_chan_ready(chan);
clean:
- release_sock(parent);
+ l2cap_chan_unlock(pchan);
}
static void l2cap_conn_ready(struct l2cap_conn *conn)
@@ -3562,7 +3559,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
struct l2cap_conn_rsp rsp;
struct l2cap_chan *chan = NULL, *pchan;
- struct sock *parent, *sk = NULL;
int result, status = L2CAP_CS_NO_INFO;
u16 dcid = 0, scid = __le16_to_cpu(req->scid);
@@ -3577,10 +3573,8 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
goto sendresp;
}
- parent = pchan->sk;
-
mutex_lock(&conn->chan_lock);
- lock_sock(parent);
+ l2cap_chan_lock(pchan);
/* Check if the ACL is secure enough (if not SDP) */
if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) &&
@@ -3600,8 +3594,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
if (!chan)
goto response;
- sk = chan->sk;
-
hci_conn_hold(conn->hcon);
bacpy(&chan->src, conn->src);
@@ -3651,7 +3643,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
}
response:
- release_sock(parent);
+ l2cap_chan_unlock(pchan);
mutex_unlock(&conn->chan_lock);
sendresp:
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index cf8f187..3d76de8 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -943,6 +943,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
{
struct sock *sk, *parent = chan->data;
+ lock_sock(parent);
+
/* Check for backlog size */
if (sk_acceptq_is_full(parent)) {
BT_DBG("backlog full %d", parent->sk_ack_backlog);
@@ -960,6 +962,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
bt_accept_enqueue(parent, sk);
+ release_sock(parent);
+
return l2cap_pi(sk)->chan;
}
--
1.8.0.2
^ permalink raw reply related
* [PATCH 10/16] Bluetooth: Remove socket lock from state_change() in l2cap_core
From: Gustavo Padovan @ 2013-01-10 7:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1357804073-31582-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This simplifies a lot the state change handling inside l2cap_core.c,
we got rid of __l2cap_state_change() and l2cap_state_change() doesn't lock
the socket anymore, instead the socket is locked inside the ops user code
in l2cap_sock.c.
In some places we were not using the locked version, and now we are using
it. There is no side effect in locking the socket in these places.
Handle the operation of lock the socket to ops user benefit A2MP, since
there is no socket lock there it doesn't need any special function in
l2cap work without touching socket locks.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 32 +++++++-------------------------
net/bluetooth/l2cap_sock.c | 4 ++++
2 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 110a702..2c4458a 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -210,7 +210,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn)
return 0;
}
-static void __l2cap_state_change(struct l2cap_chan *chan, int state)
+static void l2cap_state_change(struct l2cap_chan *chan, int state)
{
BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state),
state_to_string(state));
@@ -219,33 +219,16 @@ static void __l2cap_state_change(struct l2cap_chan *chan, int state)
chan->ops->state_change(chan, state, 0);
}
-static void l2cap_state_change(struct l2cap_chan *chan, int state)
-{
- struct sock *sk = chan->sk;
-
- lock_sock(sk);
- __l2cap_state_change(chan, state);
- release_sock(sk);
-}
-
static void l2cap_state_change_and_error(struct l2cap_chan *chan, int state,
int err)
{
- struct sock *sk = chan->sk;
-
- lock_sock(sk);
chan->state = state;
chan->ops->state_change(chan, state, err);
- release_sock(sk);
}
static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err)
{
- struct sock *sk = chan->sk;
-
- lock_sock(sk);
chan->ops->state_change(chan, chan->state, err);
- release_sock(sk);
}
static void __set_retrans_timer(struct l2cap_chan *chan)
@@ -1219,7 +1202,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
mutex_lock(&conn->chan_lock);
list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
- struct sock *sk = chan->sk;
l2cap_chan_lock(chan);
@@ -3639,7 +3621,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) {
if (l2cap_chan_check_security(chan)) {
if (test_bit(CONN_DEFER_SETUP, &chan->conn_state)) {
- __l2cap_state_change(chan, BT_CONNECT2);
+ l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHOR_PEND;
chan->ops->defer(chan);
@@ -3649,21 +3631,21 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
* physical link is up.
*/
if (amp_id) {
- __l2cap_state_change(chan, BT_CONNECT2);
+ l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
} else {
- __l2cap_state_change(chan, BT_CONFIG);
+ l2cap_state_change(chan, BT_CONFIG);
result = L2CAP_CR_SUCCESS;
}
status = L2CAP_CS_NO_INFO;
}
} else {
- __l2cap_state_change(chan, BT_CONNECT2);
+ l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHEN_PEND;
}
} else {
- __l2cap_state_change(chan, BT_CONNECT2);
+ l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
status = L2CAP_CS_NO_INFO;
}
@@ -4542,7 +4524,7 @@ static void l2cap_do_create(struct l2cap_chan *chan, int result,
sizeof(rsp), &rsp);
if (result == L2CAP_CR_SUCCESS) {
- __l2cap_state_change(chan, BT_CONFIG);
+ l2cap_state_change(chan, BT_CONFIG);
set_bit(CONF_REQ_SENT, &chan->conf_state);
l2cap_send_cmd(chan->conn, l2cap_get_ident(chan->conn),
L2CAP_CONF_REQ,
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 6a95d37..cf8f187 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1052,10 +1052,14 @@ static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state,
{
struct sock *sk = chan->data;
+ lock_sock(sk);
+
sk->sk_state = state;
if (err)
sk->sk_err = err;
+
+ release_sock(sk);
}
static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
--
1.8.0.2
^ 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