Bluetooth: Storing Link key persistantly based on the Auth Req.
Store the link key persistently if one of the following is true:
1. this is a legacy link key
2. this is a changed combination key and there was a previously
stored one
3. neither local nor remote side had no-bonding as a requirement
4. the local side had dedicated bonding as a requirement
5. the remote side is using dedicated bonding since in that case
also the local requirements are set to dedicated bonding
If none of the above match only keep the link key around for
this connection and set the temporary flag for the device.
CRs-Fixed: 309161
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 4353f9f..57fdcc1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1128,11 +1128,22 @@
key->pin_len = pin_len;
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
+ /* Store the link key persistently if one of the following is true:
+ * 1. the remote side is using dedicated bonding since in that case
+ * also the local requirements are set to dedicated bonding
+ * 2. the local side had dedicated bonding as a requirement
+ * 3. this is a legacy link key
+ * 4. this is a changed combination key and there was a previously
+ * stored one
+ * If none of the above match only keep the link key around for
+ * this connection and set the temporary flag for the device.
+ */
if (conn) {
- if (conn->remote_auth > 0x01)
- bonded = 1;
- else if (conn->auth_initiator && conn->auth_type > 0x01)
+ if ((conn->remote_auth > 0x01) ||
+ (conn->auth_initiator && conn->auth_type > 0x01) ||
+ (key->type < 0x03) ||
+ (key->type == 0x06 && old_key_type != 0xff))
bonded = 1;
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 17a6f12..e2d6490 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1084,9 +1084,6 @@
BT_DBG("%s status 0x%x", hdev->name, status);
- if (!status)
- return;
-
cp = hci_sent_cmd_data(hdev, HCI_OP_AUTH_REQUESTED);
if (!cp)
return;
@@ -1095,10 +1092,11 @@
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
if (conn) {
- if (conn->state == BT_CONFIG) {
+ if (status && conn->state == BT_CONFIG) {
hci_proto_connect_cfm(conn, status);
hci_conn_put(conn);
}
+ conn->auth_initiator = 1;
}
hci_dev_unlock(hdev);