From: Szymon Janc <szymon.janc@codecoup.pl>
To: Martin Fuzzey <mfuzzey@parkeon.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [BlueZ PATCH 1/3] android: Do not fail if empty keyset cannot be loaded
Date: Wed, 11 Oct 2017 09:32:43 +0200 [thread overview]
Message-ID: <3195897.6uX0vmqWOl@ix> (raw)
In-Reply-To: <20171010092751.30705.10296.stgit@localhost>
Hi Martin,
On Tuesday, 10 October 2017 11:27:51 CEST Martin Fuzzey wrote:
> On startup the keys are loaded, even if the keyset is empty.
> As mentionned in a comment says this is to erase any keys in the kernel.
>
> However BLE only devices do not support loading keys (the operation always
> returns unsupported error code).
>
> So, if we get an unsupported operation error, and if the keyset is empty,
> ignore and continue.
>
Yes, when BlueZ for Android was developed there were not so many single mode
devices around that could be used:)
Would it make sense to check if BR/EDR supported and only try to load it in
that case?
> Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
We don't use s-o-b for userspace patches.
> ---
> android/bluetooth.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 51a31fe..8ea521e 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -2531,13 +2531,18 @@ static void register_mgmt_handlers(void)
> NULL, NULL);
> }
>
> +struct load_link_keys_userdata {
> + bt_bluetooth_ready cb;
> + size_t key_count;
> +};
> +
> static void load_link_keys_complete(uint8_t status, uint16_t length,
> const void *param, void *user_data)
> {
> - bt_bluetooth_ready cb = user_data;
> + struct load_link_keys_userdata *ud = user_data;
> int err;
>
> - if (status) {
> + if (status && !((status == MGMT_STATUS_NOT_SUPPORTED && ud->key_count ==
> 0))) { error("Failed to load link keys for index %u: %s (0x%02x)",
> adapter.index, mgmt_errstr(status), status);
> err = -EIO;
> @@ -2546,17 +2551,20 @@ static void load_link_keys_complete(uint8_t status,
> uint16_t length,
>
> DBG("status %u", status);
>
> - cb(0, &adapter.bdaddr);
> + ud->cb(0, &adapter.bdaddr);
> + g_free(ud);
> return;
>
> failed:
> - cb(err, NULL);
> + ud->cb(err, NULL);
> + g_free(ud);
> }
>
> static void load_link_keys(GSList *keys, bt_bluetooth_ready cb)
> {
> struct mgmt_cp_load_link_keys *cp;
> struct mgmt_link_key_info *key;
> + struct load_link_keys_userdata *req_ud;
> size_t key_count, cp_size;
> unsigned int id;
>
> @@ -2578,13 +2586,18 @@ static void load_link_keys(GSList *keys,
> bt_bluetooth_ready cb) for (key = cp->keys; keys != NULL; keys =
> g_slist_next(keys), key++) memcpy(key, keys->data, sizeof(*key));
>
> + req_ud = g_malloc0(sizeof(*req_ud));
> + req_ud->cb = cb;
> + req_ud->key_count = key_count;
> +
> id = mgmt_send(mgmt_if, MGMT_OP_LOAD_LINK_KEYS, adapter.index,
> - cp_size, cp, load_link_keys_complete, cb, NULL);
> + cp_size, cp, load_link_keys_complete, req_ud, NULL);
>
> g_free(cp);
>
> if (id == 0) {
> error("Failed to load link keys");
> + g_free(req_ud);
> cb(-EIO, NULL);
> }
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
pozdrawiam
Szymon Janc
next prev parent reply other threads:[~2017-10-11 7:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 9:27 [PATCH BlueZ 0/3] android: Add LE Peripheral role support Martin Fuzzey
2017-10-10 9:27 ` [BlueZ PATCH 1/3] android: Do not fail if empty keyset cannot be loaded Martin Fuzzey
2017-10-11 7:32 ` Szymon Janc [this message]
2017-10-10 9:27 ` [BlueZ PATCH 2/3] android: Get max advertising instances from kernel Martin Fuzzey
2017-10-10 9:27 ` [BlueZ PATCH 3/3] android: Enable multiadvertising Martin Fuzzey
2017-10-11 7:33 ` Szymon Janc
2017-10-13 13:32 ` Martin Fuzzey
2017-10-11 10:15 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3195897.6uX0vmqWOl@ix \
--to=szymon.janc@codecoup.pl \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mfuzzey@parkeon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).