* [PATCH v2] Bluetooth: Fix ATT socket backwards compatibility with user space
From: johan.hedberg @ 2013-10-18 8:49 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Old user space versions bind the Attribute Protocol socket to
BDADDR_BREDR when they should be using BDADDR_LE_PUBLIC or
BDADDR_LE_RANDOM. The kernel recently introduced stricter checks on the
socket parameters but we need to punch this hole for old user space
versions to keep them working.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/l2cap_sock.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 34e5a58..1f326d9 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -159,8 +159,31 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
return -EINVAL;
- if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
- return -EINVAL;
+ /* Check that the socket wasn't bound to something that
+ * conflicts with the address given to connect(). If chan->src
+ * is BDADDR_ANY it means bind() was never used, in which case
+ * chan->src_type and la.l2_bdaddr_type do not need to match.
+ */
+ if (chan->src_type == BDADDR_BREDR && bacmp(&chan->src, BDADDR_ANY) &&
+ bdaddr_type_is_le(la.l2_bdaddr_type)) {
+ /* Old user space versions will try to incorrectly bind
+ * the ATT socket using BDADDR_BREDR. We need to accept
+ * this and fix up the source address type only when
+ * both the source CID and destination CID indicate
+ * ATT. Anything else is an invalid combination.
+ */
+ if (chan->scid != L2CAP_CID_ATT ||
+ la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
+ return -EINVAL;
+
+ /* We don't have the hdev available here to make a
+ * better decision on random vs public, but since all
+ * user space versions that exhibit this issue anyway do
+ * not support random local addresses assuming public
+ * here is good enough.
+ */
+ chan->src_type = BDADDR_LE_PUBLIC;
+ }
if (chan->src_type != BDADDR_BREDR && la.l2_bdaddr_type == BDADDR_BREDR)
return -EINVAL;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCHv2 2/2] android: Make toool compile on Android 4.2.2
From: Szymon Janc @ 2013-10-18 8:09 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1381999828-29649-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> On our current target the tools cannot be compiled.
> ---
> android/Android.mk | 2 ++
> android/client/if-bt.c | 4 ++++
> android/client/if-main.h | 3 +++
> android/client/textconv.c | 2 ++
> 4 files changed, 11 insertions(+)
>
> diff --git a/android/Android.mk b/android/Android.mk
> index f59afc6..e63add9 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -92,6 +92,8 @@ LOCAL_SRC_FILES := \
> client/textconv.c \
> client/if-bt.c \
>
> +LOCAL_CFLAGS := -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
I suppose we should also define this for autotools build. Otherwise this
will not be build on Linux.
> +
> LOCAL_SHARED_LIBRARIES := libhardware
>
> LOCAL_MODULE_TAGS := optional
> diff --git a/android/client/if-bt.c b/android/client/if-bt.c
> index 90ef732..6aadeef 100644
> --- a/android/client/if-bt.c
> +++ b/android/client/if-bt.c
> @@ -277,7 +277,9 @@ static bt_callbacks_t bt_callbacks = {
> .acl_state_changed_cb = acl_state_changed_cb,
> .thread_evt_cb = thread_evt_cb,
> .dut_mode_recv_cb = dut_mode_recv_cb,
> +#if PLATFORM_SDK_VERSION > 17
> .le_test_mode_cb = le_test_mode_cb
> +#endif
> };
>
> static void init_p(int argc, const char **argv)
> @@ -577,8 +579,10 @@ static void get_profile_interface_p(int argc, const char **argv)
> pif = &dummy; /* TODO: change when if_hh is there */
> else if (strcmp(BT_PROFILE_PAN_ID, id) == 0)
> pif = &dummy; /* TODO: change when if_pan is there */
> +#if PLATFORM_SDK_VERSION > 17
> else if (strcmp(BT_PROFILE_AV_RC_ID, id) == 0)
> pif = &dummy; /* TODO: change when if_rc is there */
> +#endif
> else
> haltest_error("%s is not correct for get_profile_interface\n",
> id);
> diff --git a/android/client/if-main.h b/android/client/if-main.h
> index 9cac7ef..1cebb72 100644
> --- a/android/client/if-main.h
> +++ b/android/client/if-main.h
> @@ -35,7 +35,10 @@
> #include <hardware/bt_sock.h>
> #include <hardware/bt_hf.h>
> #include <hardware/bt_hl.h>
> +
> +#if PLATFORM_SDK_VERSION > 17
> #include <hardware/bt_rc.h>
> +#endif
>
> #include "textconv.h"
>
> diff --git a/android/client/textconv.c b/android/client/textconv.c
> index eebad70..f38e368 100644
> --- a/android/client/textconv.c
> +++ b/android/client/textconv.c
> @@ -94,7 +94,9 @@ INTMAP(bt_property_type_t, -1, "(unknown)")
> DELEMENT(BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT),
> DELEMENT(BT_PROPERTY_REMOTE_FRIENDLY_NAME),
> DELEMENT(BT_PROPERTY_REMOTE_RSSI),
> +#if PLATFORM_SDK_VERSION > 17
> DELEMENT(BT_PROPERTY_REMOTE_VERSION_INFO),
> +#endif
> DELEMENT(BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP),
> ENDMAP
>
>
--
BR
Szymon Janc
^ permalink raw reply
* Re: [PATCH] Bluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c
From: Johan Hedberg @ 2013-10-18 7:51 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382062562-20113-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Thu, Oct 17, 2013, Marcel Holtmann wrote:
> Move the debugfs configuration directly into hci_core.c and only expose
> it when the controller actually support BR/EDR sniff power saving mode.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++
> net/bluetooth/hci_sysfs.c | 91 ----------------------------------------------
> 2 files changed, 93 insertions(+), 91 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/8] Bluetooth: Add address type to device blacklist table
From: Johan Hedberg @ 2013-10-18 7:50 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382055860-12572-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Thu, Oct 17, 2013, Marcel Holtmann wrote:
> The device blacklist is not taking care of the address type. Actually
> store the address type in the list entries and also use them when
> looking up addresses in the table.
>
> This is actually a serious bug. When adding a LE public address to
> the blacklist, then it would be blocking a device on BR/EDR. And this
> is not the expected behavior.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci_core.h | 3 ++-
> net/bluetooth/hci_core.c | 21 +++++++++++----------
> net/bluetooth/hci_event.c | 2 +-
> 3 files changed, 14 insertions(+), 12 deletions(-)
All eight patches have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: How to contribute
From: Luiz Augusto von Dentz @ 2013-10-18 7:48 UTC (permalink / raw)
To: Tim Wei; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAKCXgJ25JzJ7H4sYdA6z7EFZYNC1OBpZ_rwPvLkgAirbqDd74A@mail.gmail.com>
Hi Tim,
On Fri, Oct 18, 2013 at 5:36 AM, Tim Wei <junping.wei@gmail.com> wrote:
> I just fixed a bug in kernel. How can I contribute it?
> My base version is Linux kernel 3.9.6. Should I download the latest
> kernel and check whether it has been fixed?
Any patch going upstream should probably be based on bluetooth-next:
https://git.kernel.org/cgit/linux/kernel/git/bluetooth/bluetooth-next.git/
Patches are expected to be send via git commit -s <try to be as
descriptive as possible in the commit message> + git format-patch +
git send-email like any other kernel patch and please be patient
sometimes the patches takes a while to be reviewed because the
maintainers are busy.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix ATT socket backwards compatibility with user space
From: Marcel Holtmann @ 2013-10-18 7:48 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20131018070643.GA22824@x220.p-661hnu-f1>
Hi Johan,
>>> Old user space versions bind the Attribute Protocol socket to
>>> BDADDR_BREDR when they should be using BDADDR_LE_PUBLIC or
>>> BDADDR_LE_RANDOM. The kernel recently introduced stricter checks on the
>>> socket parameters but we need to punch this hole to them to ensure that
>>> old user space versions keep working.
>>>
>>> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
>>> ---
>>> net/bluetooth/l2cap_sock.c | 19 +++++++++++++++++--
>>> 1 file changed, 17 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
>>> index 34e5a58..a43aead 100644
>>> --- a/net/bluetooth/l2cap_sock.c
>>> +++ b/net/bluetooth/l2cap_sock.c
>>> @@ -159,8 +159,23 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
>>> if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
>>> return -EINVAL;
>>>
>>> - if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
>>> - return -EINVAL;
>>> + if (chan->src_type == BDADDR_BREDR &&
>>> + la.l2_bdaddr_type != BDADDR_BREDR) {
>>> + if (!bdaddr_type_is_le(la.l2_bdaddr_type))
>>> + return -EINVAL;
>>
>> I do not understand this. The check for that la.l2_bdaddr_type is LE
>> is done twice here.
>
> The idea was simply to try to be forward compatible in case a fourth
> address type is added, i.e. I made the assumption that
> "a != BDADDR_BREDR" might not always be the same as "bdaddr_type_is_le(a)".
>
> If you're ok with this assumption we should not just remove this extra
> if-statement but also change the higher-level one to use
> bdaddr_type_is_le() instead of making explicit comparisons with
> BDADDR_BREDR.
we need to make this one old userspace exception work. Nothing else. From there on everything else will return -EINVAL.
It is the special case where we treat BDADDR_BREDR and only that one as "auto".
>>> +
>>> + /* Old user space versions will try to bind the ATT
>>> + * socket using BDADDR_BREDR, so we have to allow this
>>> + * to pass and fix chan->src_type to the correct value.
>>> + */
>>> + if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
>>> + return -EINVAL;
>>
>> I think we should also check that the src address is BDADDR_ANY. If it
>> is not BDADDR_ANY, we should reject it as well. That is enough to make
>> old userspace work. I do not want us to be any more flexible. Or are
>> we actually bind to the right source adapter when calling connect().
>
> The user space code is correct in this regard, so I'll add the extra
> check for BDADDR_ANY.
Translating this mean that even our current userspace is utterly broken when using LE and multiple controllers. The connection will always happen on first controller due to the binding to BDADDR_ANY.
Looking at src/device.c, then one case uses the adapter address with the correct address type of BDADDR_LE_PUBLIC and the other does not provide the address type. Which means it uses the correct adapter address, but BDADDR_BREDR.
Meaning we can not even check for BDADDR_ANY here. And actually BDADDR_ANY would have been the only one where all of this made sense. And where even internally this has to work since it is the default anyway since the structure is zeroed. And you need to be able to connect() without bind().
Btw. can someone fix BtIO to just spit out an error if either a source or destination address is provided, but no address type. That is just wrong and we should just fail on such code. All newer code should even provide BDADDR_BREDR for the case when we want to connect to BR/EDR devices.
>>> + if (chan->scid != L2CAP_CID_ATT)
>>> + return -EINVAL;
>>> +
>>> + chan->src_type = BDADDR_LE_PUBLIC;
>>> + }
>>
>> I do not like the fact that we are just defaulting to BDADDR_LE_PUBLIC
>> here. It might be fine since the old userspace only ever understood
>> public addresses anyway. However I do not like it that much. And if we
>> keep it this way, then a comment needs to explain that this is good
>> enough.
>
> I'll add a comment. We could in theory extend the code to also check for
> information inside the hdev struct, but that would require too much
> complexity for the benefit since we do not have the hdev available at
> this point in the socket operations. That, considered together with the
> fact that even now user space will have a hard-coded BDADDR_LE_PUBLIC is
> imo reason enough to just keep this simple in the kernel.
With a comment in the code why we stick to BDADDR_LE_PUBLIC here is fine with me.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/5] build: Add haltest command line tester
From: Johan Hedberg @ 2013-10-18 7:16 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1382041721-19960-1-git-send-email-szymon.janc@gmail.com>
Hi Szymon,
On Thu, Oct 17, 2013, Szymon Janc wrote:
> This is intended for testing Android daemon and HAL library on Linux.
> ---
> Makefile.android | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
All five patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ] core: Fix missing adapter address type
From: Johan Hedberg @ 2013-10-18 7:08 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1382014417-23930-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Thu, Oct 17, 2013, Claudio Takahasi wrote:
> This patch fixes an invalid argument error when connecting to LE
> devices. Bind and connect address type must match.
> ---
> src/device.c | 1 +
> 1 file changed, 1 insertion(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix ATT socket backwards compatibility with user space
From: Johan Hedberg @ 2013-10-18 7:06 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <699FBB88-B7E3-4F64-92C8-54A70F1DE751@holtmann.org>
Hi Marcel,
On Fri, Oct 18, 2013, Marcel Holtmann wrote:
> > Old user space versions bind the Attribute Protocol socket to
> > BDADDR_BREDR when they should be using BDADDR_LE_PUBLIC or
> > BDADDR_LE_RANDOM. The kernel recently introduced stricter checks on the
> > socket parameters but we need to punch this hole to them to ensure that
> > old user space versions keep working.
> >
> > Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> > ---
> > net/bluetooth/l2cap_sock.c | 19 +++++++++++++++++--
> > 1 file changed, 17 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > index 34e5a58..a43aead 100644
> > --- a/net/bluetooth/l2cap_sock.c
> > +++ b/net/bluetooth/l2cap_sock.c
> > @@ -159,8 +159,23 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
> > if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
> > return -EINVAL;
> >
> > - if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
> > - return -EINVAL;
> > + if (chan->src_type == BDADDR_BREDR &&
> > + la.l2_bdaddr_type != BDADDR_BREDR) {
> > + if (!bdaddr_type_is_le(la.l2_bdaddr_type))
> > + return -EINVAL;
>
> I do not understand this. The check for that la.l2_bdaddr_type is LE
> is done twice here.
The idea was simply to try to be forward compatible in case a fourth
address type is added, i.e. I made the assumption that
"a != BDADDR_BREDR" might not always be the same as "bdaddr_type_is_le(a)".
If you're ok with this assumption we should not just remove this extra
if-statement but also change the higher-level one to use
bdaddr_type_is_le() instead of making explicit comparisons with
BDADDR_BREDR.
> > +
> > + /* Old user space versions will try to bind the ATT
> > + * socket using BDADDR_BREDR, so we have to allow this
> > + * to pass and fix chan->src_type to the correct value.
> > + */
> > + if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
> > + return -EINVAL;
>
> I think we should also check that the src address is BDADDR_ANY. If it
> is not BDADDR_ANY, we should reject it as well. That is enough to make
> old userspace work. I do not want us to be any more flexible. Or are
> we actually bind to the right source adapter when calling connect().
The user space code is correct in this regard, so I'll add the extra
check for BDADDR_ANY.
> > + if (chan->scid != L2CAP_CID_ATT)
> > + return -EINVAL;
> > +
> > + chan->src_type = BDADDR_LE_PUBLIC;
> > + }
>
> I do not like the fact that we are just defaulting to BDADDR_LE_PUBLIC
> here. It might be fine since the old userspace only ever understood
> public addresses anyway. However I do not like it that much. And if we
> keep it this way, then a comment needs to explain that this is good
> enough.
I'll add a comment. We could in theory extend the code to also check for
information inside the hdev struct, but that would require too much
complexity for the benefit since we do not have the hdev available at
this point in the socket operations. That, considered together with the
fact that even now user space will have a hard-coded BDADDR_LE_PUBLIC is
imo reason enough to just keep this simple in the kernel.
Johan
^ permalink raw reply
* How to contribute
From: Tim Wei @ 2013-10-18 2:36 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
I just fixed a bug in kernel. How can I contribute it?
My base version is Linux kernel 3.9.6. Should I download the latest
kernel and check whether it has been fixed?
Thank you and Best Regards,
Tim Wei
^ permalink raw reply
* [PATCH] Bluetooth: Move idle_timeout and sniff_{min,max}_interval to hci_core.c
From: Marcel Holtmann @ 2013-10-18 2:16 UTC (permalink / raw)
To: linux-bluetooth
Move the debugfs configuration directly into hci_core.c and only expose
it when the controller actually support BR/EDR sniff power saving mode.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_sysfs.c | 91 ----------------------------------------------
2 files changed, 93 insertions(+), 91 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a4047d6..e8058c3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -195,6 +195,90 @@ static int auto_accept_delay_get(void *data, u64 *val)
DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
auto_accept_delay_set, "%llu\n");
+static int idle_timeout_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+
+ if (val != 0 && (val < 500 || val > 3600000))
+ return -EINVAL;
+
+ hci_dev_lock(hdev);
+ hdev->idle_timeout= val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int idle_timeout_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->idle_timeout;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(idle_timeout_fops, idle_timeout_get,
+ idle_timeout_set, "%llu\n");
+
+static int sniff_min_interval_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+
+ if (val == 0 || val % 2 || val > hdev->sniff_max_interval)
+ return -EINVAL;
+
+ hci_dev_lock(hdev);
+ hdev->sniff_min_interval= val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int sniff_min_interval_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->sniff_min_interval;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(sniff_min_interval_fops, sniff_min_interval_get,
+ sniff_min_interval_set, "%llu\n");
+
+static int sniff_max_interval_set(void *data, u64 val)
+{
+ struct hci_dev *hdev = data;
+
+ if (val == 0 || val % 2 || val < hdev->sniff_min_interval)
+ return -EINVAL;
+
+ hci_dev_lock(hdev);
+ hdev->sniff_max_interval= val;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int sniff_max_interval_get(void *data, u64 *val)
+{
+ struct hci_dev *hdev = data;
+
+ hci_dev_lock(hdev);
+ *val = hdev->sniff_max_interval;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get,
+ sniff_max_interval_set, "%llu\n");
+
static int static_address_show(struct seq_file *f, void *p)
{
struct hci_dev *hdev = f->private;
@@ -923,6 +1007,15 @@ static int __hci_init(struct hci_dev *hdev)
debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
hdev, &auto_accept_delay_fops);
+ if (lmp_sniff_capable(hdev)) {
+ debugfs_create_file("idle_timeout", 0644, hdev->debugfs,
+ hdev, &idle_timeout_fops);
+ debugfs_create_file("sniff_min_interval", 0644, hdev->debugfs,
+ hdev, &sniff_min_interval_fops);
+ debugfs_create_file("sniff_max_interval", 0644, hdev->debugfs,
+ hdev, &sniff_max_interval_fops);
+ }
+
if (lmp_le_capable(hdev))
debugfs_create_file("static_address", 0444, hdev->debugfs,
hdev, &static_address_fops);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 9cbf8fe..4fac57c 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -255,87 +255,6 @@ static ssize_t show_hci_revision(struct device *dev,
return sprintf(buf, "%d\n", hdev->hci_rev);
}
-static ssize_t show_idle_timeout(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- return sprintf(buf, "%d\n", hdev->idle_timeout);
-}
-
-static ssize_t store_idle_timeout(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- unsigned int val;
- int rv;
-
- rv = kstrtouint(buf, 0, &val);
- if (rv < 0)
- return rv;
-
- if (val != 0 && (val < 500 || val > 3600000))
- return -EINVAL;
-
- hdev->idle_timeout = val;
-
- return count;
-}
-
-static ssize_t show_sniff_max_interval(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- return sprintf(buf, "%d\n", hdev->sniff_max_interval);
-}
-
-static ssize_t store_sniff_max_interval(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- u16 val;
- int rv;
-
- rv = kstrtou16(buf, 0, &val);
- if (rv < 0)
- return rv;
-
- if (val == 0 || val % 2 || val < hdev->sniff_min_interval)
- return -EINVAL;
-
- hdev->sniff_max_interval = val;
-
- return count;
-}
-
-static ssize_t show_sniff_min_interval(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- return sprintf(buf, "%d\n", hdev->sniff_min_interval);
-}
-
-static ssize_t store_sniff_min_interval(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct hci_dev *hdev = to_hci_dev(dev);
- u16 val;
- int rv;
-
- rv = kstrtou16(buf, 0, &val);
- if (rv < 0)
- return rv;
-
- if (val == 0 || val % 2 || val > hdev->sniff_max_interval)
- return -EINVAL;
-
- hdev->sniff_min_interval = val;
-
- return count;
-}
-
static DEVICE_ATTR(bus, S_IRUGO, show_bus, NULL);
static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
@@ -346,13 +265,6 @@ static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL);
static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL);
static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL);
-static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR,
- show_idle_timeout, store_idle_timeout);
-static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR,
- show_sniff_max_interval, store_sniff_max_interval);
-static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
- show_sniff_min_interval, store_sniff_min_interval);
-
static struct attribute *bt_host_attrs[] = {
&dev_attr_bus.attr,
&dev_attr_type.attr,
@@ -363,9 +275,6 @@ static struct attribute *bt_host_attrs[] = {
&dev_attr_manufacturer.attr,
&dev_attr_hci_version.attr,
&dev_attr_hci_revision.attr,
- &dev_attr_idle_timeout.attr,
- &dev_attr_sniff_max_interval.attr,
- &dev_attr_sniff_min_interval.attr,
NULL
};
--
1.8.3.1
^ permalink raw reply related
* [PATCH 8/8] Bluetooth: Include address type in blacklist debugfs data
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
The address type is important for the blacklist entries. So include
it at well.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 940da80..a4047d6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -65,7 +65,7 @@ static int blacklist_show(struct seq_file *f, void *p)
hci_dev_lock(hdev);
list_for_each_entry(b, &hdev->blacklist, list)
- seq_printf(f, "%pMR\n", &b->bdaddr);
+ seq_printf(f, "%pMR (type %u)\n", &b->bdaddr, b->bdaddr_type);
hci_dev_unlock(hdev);
return 0;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 7/8] Bluetooth: Move device_add handling into hci_register_dev
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
The device_add handling can be done directly in hci_register_dev and
device_remove within hci_unregister_dev.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 2 --
net/bluetooth/hci_core.c | 6 ++++--
net/bluetooth/hci_sysfs.c | 18 ------------------
3 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c6becda..9b5db01 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -768,8 +768,6 @@ int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
void hci_init_sysfs(struct hci_dev *hdev);
-int hci_add_sysfs(struct hci_dev *hdev);
-void hci_del_sysfs(struct hci_dev *hdev);
void hci_conn_init_sysfs(struct hci_conn *conn);
void hci_conn_add_sysfs(struct hci_conn *conn);
void hci_conn_del_sysfs(struct hci_conn *conn);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index f7ba818..940da80 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2482,7 +2482,9 @@ int hci_register_dev(struct hci_dev *hdev)
if (!IS_ERR_OR_NULL(bt_debugfs))
hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
- error = hci_add_sysfs(hdev);
+ dev_set_name(&hdev->dev, "%s", hdev->name);
+
+ error = device_add(&hdev->dev);
if (error < 0)
goto err_wqueue;
@@ -2570,7 +2572,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
rfkill_destroy(hdev->rfkill);
}
- hci_del_sysfs(hdev);
+ device_del(&hdev->dev);
debugfs_remove_recursive(hdev->debugfs);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 320a761..9cbf8fe 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -402,24 +402,6 @@ void hci_init_sysfs(struct hci_dev *hdev)
device_initialize(dev);
}
-int hci_add_sysfs(struct hci_dev *hdev)
-{
- struct device *dev = &hdev->dev;
-
- BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
-
- dev_set_name(dev, "%s", hdev->name);
-
- return device_add(dev);
-}
-
-void hci_del_sysfs(struct hci_dev *hdev)
-{
- BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
-
- device_del(&hdev->dev);
-}
-
int __init bt_sysfs_init(void)
{
bt_class = class_create(THIS_MODULE, "bluetooth");
--
1.8.3.1
^ permalink raw reply related
* [PATCH 6/8] Bluetooth: Create root debugfs directory during module init
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
Create the root Bluetooth debugfs directory during module init
and remove it on module exit.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/af_bluetooth.c | 9 ++++++++-
net/bluetooth/hci_sysfs.c | 8 --------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 1f1a111..f6a1671 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -25,6 +25,7 @@
/* Bluetooth address family and sockets. */
#include <linux/module.h>
+#include <linux/debugfs.h>
#include <asm/ioctls.h>
#include <net/bluetooth/bluetooth.h>
@@ -708,12 +709,17 @@ static struct net_proto_family bt_sock_family_ops = {
.create = bt_sock_create,
};
+struct dentry *bt_debugfs;
+EXPORT_SYMBOL_GPL(bt_debugfs);
+
static int __init bt_init(void)
{
int err;
BT_INFO("Core ver %s", VERSION);
+ bt_debugfs = debugfs_create_dir("bluetooth", NULL);
+
err = bt_sysfs_init();
if (err < 0)
return err;
@@ -754,7 +760,6 @@ error:
static void __exit bt_exit(void)
{
-
sco_exit();
l2cap_exit();
@@ -764,6 +769,8 @@ static void __exit bt_exit(void)
sock_unregister(PF_BLUETOOTH);
bt_sysfs_cleanup();
+
+ debugfs_remove_recursive(bt_debugfs);
}
subsys_initcall(bt_init);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 0e71318..320a761 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -1,6 +1,5 @@
/* Bluetooth HCI driver model support. */
-#include <linux/debugfs.h>
#include <linux/module.h>
#include <net/bluetooth/bluetooth.h>
@@ -8,9 +7,6 @@
static struct class *bt_class;
-struct dentry *bt_debugfs;
-EXPORT_SYMBOL_GPL(bt_debugfs);
-
static inline char *link_typetostr(int type)
{
switch (type) {
@@ -426,8 +422,6 @@ void hci_del_sysfs(struct hci_dev *hdev)
int __init bt_sysfs_init(void)
{
- bt_debugfs = debugfs_create_dir("bluetooth", NULL);
-
bt_class = class_create(THIS_MODULE, "bluetooth");
return PTR_ERR_OR_ZERO(bt_class);
@@ -436,6 +430,4 @@ int __init bt_sysfs_init(void)
void bt_sysfs_cleanup(void)
{
class_destroy(bt_class);
-
- debugfs_remove_recursive(bt_debugfs);
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 5/8] Bluetooth: Create HCI device debugfs directory in hci_register_dev
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
Create the debugfs directory for each HCI device directly in
hci_register_dev function and remove it during hci_unregister_dev.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 5 +++++
net/bluetooth/hci_sysfs.c | 16 +---------------
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0fb9f6d..f7ba818 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2479,6 +2479,9 @@ int hci_register_dev(struct hci_dev *hdev)
goto err;
}
+ if (!IS_ERR_OR_NULL(bt_debugfs))
+ hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
+
error = hci_add_sysfs(hdev);
if (error < 0)
goto err_wqueue;
@@ -2569,6 +2572,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
hci_del_sysfs(hdev);
+ debugfs_remove_recursive(hdev->debugfs);
+
destroy_workqueue(hdev->workqueue);
destroy_workqueue(hdev->req_workqueue);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 077037e..0e71318 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -409,32 +409,18 @@ void hci_init_sysfs(struct hci_dev *hdev)
int hci_add_sysfs(struct hci_dev *hdev)
{
struct device *dev = &hdev->dev;
- int err;
BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
dev_set_name(dev, "%s", hdev->name);
- err = device_add(dev);
- if (err < 0)
- return err;
-
- if (!bt_debugfs)
- return 0;
-
- hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
- if (!hdev->debugfs)
- return 0;
-
- return 0;
+ return device_add(dev);
}
void hci_del_sysfs(struct hci_dev *hdev)
{
BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
- debugfs_remove_recursive(hdev->debugfs);
-
device_del(&hdev->dev);
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 4/8] Bluetooth: Use IS_ERR_OR_NULL for checking bt_debugfs
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
Make sure to use IS_ERR_OR_NULL for checking the existing of the root
debugfs dentry bt_debugfs.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/l2cap_core.c | 11 +++++------
net/bluetooth/rfcomm/core.c | 14 +++++++-------
net/bluetooth/rfcomm/sock.c | 14 +++++++-------
net/bluetooth/sco.c | 13 ++++++-------
4 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8af34d2..763b741 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6833,12 +6833,11 @@ int __init l2cap_init(void)
if (err < 0)
return err;
- if (bt_debugfs) {
- l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
- NULL, &l2cap_debugfs_fops);
- if (!l2cap_debugfs)
- BT_ERR("Failed to create L2CAP debug file");
- }
+ if (IS_ERR_OR_NULL(bt_debugfs))
+ return 0;
+
+ l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs,
+ NULL, &l2cap_debugfs_fops);
return 0;
}
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 27e936a..94d06cb 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2154,13 +2154,6 @@ static int __init rfcomm_init(void)
goto unregister;
}
- if (bt_debugfs) {
- rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
- bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
- if (!rfcomm_dlc_debugfs)
- BT_ERR("Failed to create RFCOMM debug file");
- }
-
err = rfcomm_init_ttys();
if (err < 0)
goto stop;
@@ -2171,6 +2164,13 @@ static int __init rfcomm_init(void)
BT_INFO("RFCOMM ver %s", VERSION);
+ if (IS_ERR_OR_NULL(bt_debugfs))
+ return 0;
+
+ rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
+ bt_debugfs, NULL,
+ &rfcomm_dlc_debugfs_fops);
+
return 0;
cleanup:
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index df17276..c4d3d42 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -1051,15 +1051,15 @@ int __init rfcomm_init_sockets(void)
goto error;
}
- if (bt_debugfs) {
- rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
- bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
- if (!rfcomm_sock_debugfs)
- BT_ERR("Failed to create RFCOMM debug file");
- }
-
BT_INFO("RFCOMM socket layer initialized");
+ if (IS_ERR_OR_NULL(bt_debugfs))
+ return 0;
+
+ rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
+ bt_debugfs, NULL,
+ &rfcomm_sock_debugfs_fops);
+
return 0;
error:
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index a92aeba..12a0e51 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1177,15 +1177,14 @@ int __init sco_init(void)
goto error;
}
- if (bt_debugfs) {
- sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs,
- NULL, &sco_debugfs_fops);
- if (!sco_debugfs)
- BT_ERR("Failed to create SCO debug file");
- }
-
BT_INFO("SCO socket layer initialized");
+ if (IS_ERR_OR_NULL(bt_debugfs))
+ return 0;
+
+ sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs,
+ NULL, &sco_debugfs_fops);
+
return 0;
error:
--
1.8.3.1
^ permalink raw reply related
* [PATCH 3/8] Bluetooth: Move uuids debugfs entry creation into hci_core.c
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
The uuids debugfs should only be created together with the other
entries after the setup procedure has been finished.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 40 ++++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_sysfs.c | 46 ----------------------------------------------
2 files changed, 40 insertions(+), 46 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index de59bb1..0fb9f6d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -29,6 +29,7 @@
#include <linux/idr.h>
#include <linux/rfkill.h>
#include <linux/debugfs.h>
+#include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -82,6 +83,43 @@ static const struct file_operations blacklist_fops = {
.release = single_release,
};
+static int uuids_show(struct seq_file *f, void *p)
+{
+ struct hci_dev *hdev = f->private;
+ struct bt_uuid *uuid;
+
+ hci_dev_lock(hdev);
+ list_for_each_entry(uuid, &hdev->uuids, list) {
+ u32 data0, data5;
+ u16 data1, data2, data3, data4;
+
+ 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-%.4x%.8x\n",
+ data0, data1, data2, data3, data4, data5);
+ }
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int uuids_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, uuids_show, inode->i_private);
+}
+
+static const struct file_operations uuids_fops = {
+ .open = uuids_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int inquiry_cache_show(struct seq_file *f, void *p)
{
struct hci_dev *hdev = f->private;
@@ -872,6 +910,8 @@ static int __hci_init(struct hci_dev *hdev)
debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
&blacklist_fops);
+ debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
+
if (lmp_bredr_capable(hdev)) {
debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
hdev, &inquiry_cache_fops);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 863e313..077037e 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -2,7 +2,6 @@
#include <linux/debugfs.h>
#include <linux/module.h>
-#include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -396,49 +395,6 @@ static struct device_type bt_host = {
.release = bt_host_release,
};
-static void print_bt_uuid(struct seq_file *f, u8 *uuid)
-{
- u32 data0, data5;
- u16 data1, data2, data3, data4;
-
- 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-%.4x%.8x\n",
- data0, data1, data2, data3, data4, data5);
-}
-
-static int uuids_show(struct seq_file *f, void *p)
-{
- struct hci_dev *hdev = f->private;
- struct bt_uuid *uuid;
-
- hci_dev_lock(hdev);
-
- list_for_each_entry(uuid, &hdev->uuids, list)
- print_bt_uuid(f, uuid->uuid);
-
- hci_dev_unlock(hdev);
-
- return 0;
-}
-
-static int uuids_open(struct inode *inode, struct file *file)
-{
- return single_open(file, uuids_show, inode->i_private);
-}
-
-static const struct file_operations uuids_fops = {
- .open = uuids_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
void hci_init_sysfs(struct hci_dev *hdev)
{
struct device *dev = &hdev->dev;
@@ -470,8 +426,6 @@ int hci_add_sysfs(struct hci_dev *hdev)
if (!hdev->debugfs)
return 0;
- debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
-
return 0;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/8] Bluetooth: Move blacklist debugfs entry creation into hci_core.c
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
The blacklist debugfs should only be created together with the other
entries after the setup procedure has been finished.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 28 ++++++++++++++++++++++++++++
net/bluetooth/hci_sysfs.c | 30 ------------------------------
2 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2376c30..de59bb1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -57,6 +57,31 @@ static void hci_notify(struct hci_dev *hdev, int event)
/* ---- HCI debugfs entries ---- */
+static int blacklist_show(struct seq_file *f, void *p)
+{
+ struct hci_dev *hdev = f->private;
+ struct bdaddr_list *b;
+
+ hci_dev_lock(hdev);
+ list_for_each_entry(b, &hdev->blacklist, list)
+ seq_printf(f, "%pMR\n", &b->bdaddr);
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+static int blacklist_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, blacklist_show, inode->i_private);
+}
+
+static const struct file_operations blacklist_fops = {
+ .open = blacklist_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int inquiry_cache_show(struct seq_file *f, void *p)
{
struct hci_dev *hdev = f->private;
@@ -844,6 +869,9 @@ static int __hci_init(struct hci_dev *hdev)
if (!test_bit(HCI_SETUP, &hdev->dev_flags))
return 0;
+ debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
+ &blacklist_fops);
+
if (lmp_bredr_capable(hdev)) {
debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
hdev, &inquiry_cache_fops);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index a141960..863e313 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -396,33 +396,6 @@ static struct device_type bt_host = {
.release = bt_host_release,
};
-static int blacklist_show(struct seq_file *f, void *p)
-{
- struct hci_dev *hdev = f->private;
- struct bdaddr_list *b;
-
- hci_dev_lock(hdev);
-
- list_for_each_entry(b, &hdev->blacklist, list)
- seq_printf(f, "%pMR\n", &b->bdaddr);
-
- hci_dev_unlock(hdev);
-
- return 0;
-}
-
-static int blacklist_open(struct inode *inode, struct file *file)
-{
- return single_open(file, blacklist_show, inode->i_private);
-}
-
-static const struct file_operations blacklist_fops = {
- .open = blacklist_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
{
u32 data0, data5;
@@ -497,9 +470,6 @@ int hci_add_sysfs(struct hci_dev *hdev)
if (!hdev->debugfs)
return 0;
- debugfs_create_file("blacklist", 0444, hdev->debugfs,
- hdev, &blacklist_fops);
-
debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
return 0;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/8] Bluetooth: Add address type to device blacklist table
From: Marcel Holtmann @ 2013-10-18 0:24 UTC (permalink / raw)
To: linux-bluetooth
The device blacklist is not taking care of the address type. Actually
store the address type in the list entries and also use them when
looking up addresses in the table.
This is actually a serious bug. When adding a LE public address to
the blacklist, then it would be blocking a device on BR/EDR. And this
is not the expected behavior.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 3 ++-
net/bluetooth/hci_core.c | 21 +++++++++++----------
net/bluetooth/hci_event.c | 2 +-
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 07c2da4..c6becda 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -81,6 +81,7 @@ struct hci_conn_hash {
struct bdaddr_list {
struct list_head list;
bdaddr_t bdaddr;
+ u8 bdaddr_type;
};
struct bt_uuid {
@@ -732,7 +733,7 @@ int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
int hci_inquiry(void __user *arg);
struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
- bdaddr_t *bdaddr);
+ bdaddr_t *bdaddr, u8 type);
int hci_blacklist_clear(struct hci_dev *hdev);
int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b7c4ada..2376c30 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2158,13 +2158,15 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
return 0;
}
-struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr)
+struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
+ bdaddr_t *bdaddr, u8 type)
{
struct bdaddr_list *b;
- list_for_each_entry(b, &hdev->blacklist, list)
- if (bacmp(bdaddr, &b->bdaddr) == 0)
+ list_for_each_entry(b, &hdev->blacklist, list) {
+ if (!bacmp(&b->bdaddr, bdaddr) && b->bdaddr_type == type)
return b;
+ }
return NULL;
}
@@ -2174,9 +2176,7 @@ int hci_blacklist_clear(struct hci_dev *hdev)
struct list_head *p, *n;
list_for_each_safe(p, n, &hdev->blacklist) {
- struct bdaddr_list *b;
-
- b = list_entry(p, struct bdaddr_list, list);
+ struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
list_del(p);
kfree(b);
@@ -2189,10 +2189,10 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
{
struct bdaddr_list *entry;
- if (bacmp(bdaddr, BDADDR_ANY) == 0)
+ if (!bacmp(bdaddr, BDADDR_ANY))
return -EBADF;
- if (hci_blacklist_lookup(hdev, bdaddr))
+ if (hci_blacklist_lookup(hdev, bdaddr, type))
return -EEXIST;
entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
@@ -2200,6 +2200,7 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
return -ENOMEM;
bacpy(&entry->bdaddr, bdaddr);
+ entry->bdaddr_type = type;
list_add(&entry->list, &hdev->blacklist);
@@ -2210,10 +2211,10 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
{
struct bdaddr_list *entry;
- if (bacmp(bdaddr, BDADDR_ANY) == 0)
+ if (!bacmp(bdaddr, BDADDR_ANY))
return hci_blacklist_clear(hdev);
- entry = hci_blacklist_lookup(hdev, bdaddr);
+ entry = hci_blacklist_lookup(hdev, bdaddr, type);
if (!entry)
return -ENOENT;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6c3b193..e43de98 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1692,7 +1692,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
&flags);
if ((mask & HCI_LM_ACCEPT) &&
- !hci_blacklist_lookup(hdev, &ev->bdaddr)) {
+ !hci_blacklist_lookup(hdev, &ev->bdaddr, BDADDR_BREDR)) {
/* Connection accepted */
struct inquiry_entry *ie;
struct hci_conn *conn;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Fix ATT socket backwards compatibility with user space
From: Marcel Holtmann @ 2013-10-17 22:36 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1382037386-17396-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> Old user space versions bind the Attribute Protocol socket to
> BDADDR_BREDR when they should be using BDADDR_LE_PUBLIC or
> BDADDR_LE_RANDOM. The kernel recently introduced stricter checks on the
> socket parameters but we need to punch this hole to them to ensure that
> old user space versions keep working.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_sock.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 34e5a58..a43aead 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -159,8 +159,23 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
> if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
> return -EINVAL;
>
> - if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR)
> - return -EINVAL;
> + if (chan->src_type == BDADDR_BREDR &&
> + la.l2_bdaddr_type != BDADDR_BREDR) {
> + if (!bdaddr_type_is_le(la.l2_bdaddr_type))
> + return -EINVAL;
I do not understand this. The check for that la.l2_bdaddr_type is LE is done twice here.
> +
> + /* Old user space versions will try to bind the ATT
> + * socket using BDADDR_BREDR, so we have to allow this
> + * to pass and fix chan->src_type to the correct value.
> + */
> + if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
> + return -EINVAL;
I think we should also check that the src address is BDADDR_ANY. If it is not BDADDR_ANY, we should reject it as well. That is enough to make old userspace work. I do not want us to be any more flexible. Or are we actually bind to the right source adapter when calling connect().
> +
> + if (chan->scid != L2CAP_CID_ATT)
> + return -EINVAL;
> +
> + chan->src_type = BDADDR_LE_PUBLIC;
> + }
I do not like the fact that we are just defaulting to BDADDR_LE_PUBLIC here. It might be fine since the old userspace only ever understood public addresses anyway. However I do not like it that much. And if we keep it this way, then a comment needs to explain that this is good enough.
>
> if (chan->src_type != BDADDR_BREDR && la.l2_bdaddr_type == BDADDR_BREDR)
> return -EINVAL;
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add hci_h4p driver
From: Marcel Holtmann @ 2013-10-17 22:11 UTC (permalink / raw)
To: Pali Rohár
Cc: Gustavo Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
linux-bluetooth,
Ивайло Димитров,
Joni Lapilainen, Sebastian Reichel, Aaro Koskinen
In-Reply-To: <201310172225.33343@pali>
Hi Pali,
>> This driver adding support for Nokia N900 bluetooth hardware
>>
>> Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
>> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
>> ---
>> drivers/bluetooth/Kconfig | 10 +
>> drivers/bluetooth/Makefile | 2 +
>> drivers/bluetooth/hci_h4p/Makefile | 7 +
>> drivers/bluetooth/hci_h4p/core.c | 1085
>> +++++++++++++++++++++++++++++++++
>> drivers/bluetooth/hci_h4p/fw-bcm.c | 149 +++++
>> drivers/bluetooth/hci_h4p/fw-csr.c | 152 +++++
>> drivers/bluetooth/hci_h4p/fw-ti1273.c | 113 ++++
>> drivers/bluetooth/hci_h4p/fw.c | 166 +++++
>> drivers/bluetooth/hci_h4p/hci_h4p.h | 238 ++++++++
>> drivers/bluetooth/hci_h4p/uart.c | 203 ++++++
>> include/linux/bluetooth/hci_h4p.h | 41 ++
>> 11 files changed, 2166 insertions(+)
>> create mode 100644 drivers/bluetooth/hci_h4p/Makefile
>> create mode 100644 drivers/bluetooth/hci_h4p/core.c
>> create mode 100644 drivers/bluetooth/hci_h4p/fw-bcm.c
>> create mode 100644 drivers/bluetooth/hci_h4p/fw-csr.c
>> create mode 100644 drivers/bluetooth/hci_h4p/fw-ti1273.c
>> create mode 100644 drivers/bluetooth/hci_h4p/fw.c
>> create mode 100644 drivers/bluetooth/hci_h4p/hci_h4p.h
>> create mode 100644 drivers/bluetooth/hci_h4p/uart.c
>> create mode 100644 include/linux/bluetooth/hci_h4p.h
>>
>
> Can somebody look & comment this patch? What is needed to be part
> of upstream kernel?
you need to rebase against bluetooth-next at least.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose current voice setting in debugfs
From: Johan Hedberg @ 2013-10-17 20:57 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382036551-54592-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Thu, Oct 17, 2013, Marcel Holtmann wrote:
> For easier debugging of the current voice setting, expose the value
> in debugfs if the controller is BR/EDR capable.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose static address value for LE capable controllers
From: Johan Hedberg @ 2013-10-17 20:57 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382035509-43957-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Thu, Oct 17, 2013, Marcel Holtmann wrote:
> For LE capable controllers, the static address can be configured. For
> debugging purposes expose the value in debugfs.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose auto_accept_delay debugfs only when SSP is supported
From: Johan Hedberg @ 2013-10-17 20:56 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1382032486-31010-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Thu, Oct 17, 2013, Marcel Holtmann wrote:
> The auto_accept_delay debugfs entry is only valid for BR/EDR capable
> controllers that also support SSP. If SSP is not available or it is
> a LE-only single mode controller this value has no affect and so do
> not expose it.
>
> Since the value can be actually changed, switch the permissions
> to 0644 to clearly indicate that the value is indeed writeable.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 29 +++++++++++++++++++++++++++++
> net/bluetooth/hci_sysfs.c | 31 -------------------------------
> 2 files changed, 29 insertions(+), 31 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* [PATCH 5/5] build: Add missing Android files to EXTRA_DIST
From: Szymon Janc @ 2013-10-17 20:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1382041721-19960-1-git-send-email-szymon.janc@gmail.com>
From: Szymon Janc <szymon.janc@tieto.com>
---
Makefile.android | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/Makefile.android b/Makefile.android
index 00d962d..8ae3ddc 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -48,7 +48,24 @@ android_haltest_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android
endif
-EXTRA_DIST += android/Android.mk android/log.c
+EXTRA_DIST += android/Android.mk android/log.c android/device.c \
+ android/adapter.c android/main.c android/hal-msg.h \
+ android/hal.h
+
+EXTRA_DIST += android/hal_bt_sock.c android/hal_bluetooth.c
+
+EXTRA_DIST += android/client/terminal.c \
+ android/client/haltest.c \
+ android/client/hwmodule.c \
+ android/client/pollhandler.c \
+ android/client/history.c \
+ android/client/if-bt.c \
+ android/client/textconv.c \
+ android/client/textconv.h \
+ android/client/if-main.h \
+ android/client/pollhandler.h \
+ android/client/history.h \
+ android/client/terminal.h
EXTRA_DIST += android/hal-ipc-api.txt
--
1.8.4.rc3
^ 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