diff options
author | John W. Linville <linville@tuxdriver.com> | 2014-03-31 15:22:17 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-03-31 15:22:17 -0400 |
commit | 96da266e77637ae892b196f377908c51fa9f2d1a (patch) | |
tree | bf3da12850bbd46082add3060f9a5253aed144e0 /net | |
parent | 9109e17f7c3ace48629397b44db5ce06bf168644 (diff) | |
parent | a31267c30880ebdc73e6815f58c69a665052fab8 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_event.c | 63 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 3 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 20 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 3 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 87 | ||||
-rw-r--r-- | net/bluetooth/smp.h | 7 |
6 files changed, 106 insertions, 77 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a6a3d32553c5..49774912cb01 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -199,6 +199,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) | |||
199 | memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); | 199 | memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); |
200 | hdev->scan_rsp_data_len = 0; | 200 | hdev->scan_rsp_data_len = 0; |
201 | 201 | ||
202 | hdev->le_scan_type = LE_SCAN_PASSIVE; | ||
203 | |||
202 | hdev->ssp_debug_mode = 0; | 204 | hdev->ssp_debug_mode = 0; |
203 | } | 205 | } |
204 | 206 | ||
@@ -997,6 +999,25 @@ static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) | |||
997 | hci_dev_unlock(hdev); | 999 | hci_dev_unlock(hdev); |
998 | } | 1000 | } |
999 | 1001 | ||
1002 | static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) | ||
1003 | { | ||
1004 | struct hci_cp_le_set_scan_param *cp; | ||
1005 | __u8 status = *((__u8 *) skb->data); | ||
1006 | |||
1007 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1008 | |||
1009 | cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_PARAM); | ||
1010 | if (!cp) | ||
1011 | return; | ||
1012 | |||
1013 | hci_dev_lock(hdev); | ||
1014 | |||
1015 | if (!status) | ||
1016 | hdev->le_scan_type = cp->type; | ||
1017 | |||
1018 | hci_dev_unlock(hdev); | ||
1019 | } | ||
1020 | |||
1000 | static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | 1021 | static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, |
1001 | struct sk_buff *skb) | 1022 | struct sk_buff *skb) |
1002 | { | 1023 | { |
@@ -1704,6 +1725,36 @@ unlock: | |||
1704 | hci_dev_unlock(hdev); | 1725 | hci_dev_unlock(hdev); |
1705 | } | 1726 | } |
1706 | 1727 | ||
1728 | static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) | ||
1729 | { | ||
1730 | struct hci_cp_le_start_enc *cp; | ||
1731 | struct hci_conn *conn; | ||
1732 | |||
1733 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1734 | |||
1735 | if (!status) | ||
1736 | return; | ||
1737 | |||
1738 | hci_dev_lock(hdev); | ||
1739 | |||
1740 | cp = hci_sent_cmd_data(hdev, HCI_OP_LE_START_ENC); | ||
1741 | if (!cp) | ||
1742 | goto unlock; | ||
1743 | |||
1744 | conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); | ||
1745 | if (!conn) | ||
1746 | goto unlock; | ||
1747 | |||
1748 | if (conn->state != BT_CONNECTED) | ||
1749 | goto unlock; | ||
1750 | |||
1751 | hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE); | ||
1752 | hci_conn_drop(conn); | ||
1753 | |||
1754 | unlock: | ||
1755 | hci_dev_unlock(hdev); | ||
1756 | } | ||
1757 | |||
1707 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | 1758 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) |
1708 | { | 1759 | { |
1709 | __u8 status = *((__u8 *) skb->data); | 1760 | __u8 status = *((__u8 *) skb->data); |
@@ -2488,6 +2539,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2488 | hci_cc_le_set_adv_enable(hdev, skb); | 2539 | hci_cc_le_set_adv_enable(hdev, skb); |
2489 | break; | 2540 | break; |
2490 | 2541 | ||
2542 | case HCI_OP_LE_SET_SCAN_PARAM: | ||
2543 | hci_cc_le_set_scan_param(hdev, skb); | ||
2544 | break; | ||
2545 | |||
2491 | case HCI_OP_LE_SET_SCAN_ENABLE: | 2546 | case HCI_OP_LE_SET_SCAN_ENABLE: |
2492 | hci_cc_le_set_scan_enable(hdev, skb); | 2547 | hci_cc_le_set_scan_enable(hdev, skb); |
2493 | break; | 2548 | break; |
@@ -2611,6 +2666,10 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2611 | hci_cs_le_create_conn(hdev, ev->status); | 2666 | hci_cs_le_create_conn(hdev, ev->status); |
2612 | break; | 2667 | break; |
2613 | 2668 | ||
2669 | case HCI_OP_LE_START_ENC: | ||
2670 | hci_cs_le_start_enc(hdev, ev->status); | ||
2671 | break; | ||
2672 | |||
2614 | default: | 2673 | default: |
2615 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2674 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2616 | break; | 2675 | break; |
@@ -3459,8 +3518,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev, | |||
3459 | } | 3518 | } |
3460 | 3519 | ||
3461 | confirm: | 3520 | confirm: |
3462 | mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, ev->passkey, | 3521 | mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, |
3463 | confirm_hint); | 3522 | le32_to_cpu(ev->passkey), confirm_hint); |
3464 | 3523 | ||
3465 | unlock: | 3524 | unlock: |
3466 | hci_dev_unlock(hdev); | 3525 | hci_dev_unlock(hdev); |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 33cd5615ff1e..f59e00c2daa9 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -360,7 +360,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, | |||
360 | 360 | ||
361 | BT_DBG("sock %p, sk %p", sock, sk); | 361 | BT_DBG("sock %p, sk %p", sock, sk); |
362 | 362 | ||
363 | if (peer && sk->sk_state != BT_CONNECTED) | 363 | if (peer && sk->sk_state != BT_CONNECTED && |
364 | sk->sk_state != BT_CONNECT && sk->sk_state != BT_CONNECT2) | ||
364 | return -ENOTCONN; | 365 | return -ENOTCONN; |
365 | 366 | ||
366 | memset(la, 0, sizeof(struct sockaddr_l2)); | 367 | memset(la, 0, sizeof(struct sockaddr_l2)); |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 96670f581bb0..d2d4e0d5aed0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2762,23 +2762,11 @@ static struct pending_cmd *find_pairing(struct hci_conn *conn) | |||
2762 | 2762 | ||
2763 | static void pairing_complete(struct pending_cmd *cmd, u8 status) | 2763 | static void pairing_complete(struct pending_cmd *cmd, u8 status) |
2764 | { | 2764 | { |
2765 | const struct mgmt_cp_pair_device *cp = cmd->param; | ||
2766 | struct mgmt_rp_pair_device rp; | 2765 | struct mgmt_rp_pair_device rp; |
2767 | struct hci_conn *conn = cmd->user_data; | 2766 | struct hci_conn *conn = cmd->user_data; |
2768 | 2767 | ||
2769 | /* If we had a pairing failure we might have already received | 2768 | bacpy(&rp.addr.bdaddr, &conn->dst); |
2770 | * the remote Identity Address Information and updated the | 2769 | rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); |
2771 | * hci_conn variables with it, however we would not yet have | ||
2772 | * notified user space of the resolved identity. Therefore, use | ||
2773 | * the address given in the Pair Device command in case the | ||
2774 | * pairing failed. | ||
2775 | */ | ||
2776 | if (status) { | ||
2777 | memcpy(&rp.addr, &cp->addr, sizeof(rp.addr)); | ||
2778 | } else { | ||
2779 | bacpy(&rp.addr.bdaddr, &conn->dst); | ||
2780 | rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); | ||
2781 | } | ||
2782 | 2770 | ||
2783 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, | 2771 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, |
2784 | &rp, sizeof(rp)); | 2772 | &rp, sizeof(rp)); |
@@ -5338,7 +5326,7 @@ void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
5338 | } | 5326 | } |
5339 | 5327 | ||
5340 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | 5328 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, |
5341 | u8 link_type, u8 addr_type, __le32 value, | 5329 | u8 link_type, u8 addr_type, u32 value, |
5342 | u8 confirm_hint) | 5330 | u8 confirm_hint) |
5343 | { | 5331 | { |
5344 | struct mgmt_ev_user_confirm_request ev; | 5332 | struct mgmt_ev_user_confirm_request ev; |
@@ -5348,7 +5336,7 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
5348 | bacpy(&ev.addr.bdaddr, bdaddr); | 5336 | bacpy(&ev.addr.bdaddr, bdaddr); |
5349 | ev.addr.type = link_to_bdaddr(link_type, addr_type); | 5337 | ev.addr.type = link_to_bdaddr(link_type, addr_type); |
5350 | ev.confirm_hint = confirm_hint; | 5338 | ev.confirm_hint = confirm_hint; |
5351 | ev.value = value; | 5339 | ev.value = cpu_to_le32(value); |
5352 | 5340 | ||
5353 | return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev), | 5341 | return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev), |
5354 | NULL); | 5342 | NULL); |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index c024e715512f..eabd25ab5ad9 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -534,7 +534,8 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int * | |||
534 | 534 | ||
535 | BT_DBG("sock %p, sk %p", sock, sk); | 535 | BT_DBG("sock %p, sk %p", sock, sk); |
536 | 536 | ||
537 | if (peer && sk->sk_state != BT_CONNECTED) | 537 | if (peer && sk->sk_state != BT_CONNECTED && |
538 | sk->sk_state != BT_CONNECT && sk->sk_state != BT_CONNECT2) | ||
538 | return -ENOTCONN; | 539 | return -ENOTCONN; |
539 | 540 | ||
540 | memset(sa, 0, sizeof(*sa)); | 541 | memset(sa, 0, sizeof(*sa)); |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 2a7ee7f6cd8b..dfb4e1161c10 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -387,6 +387,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, | |||
387 | if (!(auth & SMP_AUTH_BONDING) && method == JUST_CFM) | 387 | if (!(auth & SMP_AUTH_BONDING) && method == JUST_CFM) |
388 | method = JUST_WORKS; | 388 | method = JUST_WORKS; |
389 | 389 | ||
390 | /* Don't confirm locally initiated pairing attempts */ | ||
391 | if (method == JUST_CFM && test_bit(SMP_FLAG_INITIATOR, | ||
392 | &smp->smp_flags)) | ||
393 | method = JUST_WORKS; | ||
394 | |||
390 | /* If Just Works, Continue with Zero TK */ | 395 | /* If Just Works, Continue with Zero TK */ |
391 | if (method == JUST_WORKS) { | 396 | if (method == JUST_WORKS) { |
392 | set_bit(SMP_FLAG_TK_VALID, &smp->smp_flags); | 397 | set_bit(SMP_FLAG_TK_VALID, &smp->smp_flags); |
@@ -422,10 +427,14 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, | |||
422 | if (method == REQ_PASSKEY) | 427 | if (method == REQ_PASSKEY) |
423 | ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, | 428 | ret = mgmt_user_passkey_request(hcon->hdev, &hcon->dst, |
424 | hcon->type, hcon->dst_type); | 429 | hcon->type, hcon->dst_type); |
430 | else if (method == JUST_CFM) | ||
431 | ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, | ||
432 | hcon->type, hcon->dst_type, | ||
433 | passkey, 1); | ||
425 | else | 434 | else |
426 | ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, | 435 | ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst, |
427 | hcon->type, hcon->dst_type, | 436 | hcon->type, hcon->dst_type, |
428 | cpu_to_le32(passkey), 0); | 437 | passkey, 0); |
429 | 438 | ||
430 | hci_dev_unlock(hcon->hdev); | 439 | hci_dev_unlock(hcon->hdev); |
431 | 440 | ||
@@ -547,20 +556,6 @@ error: | |||
547 | smp_failure(conn, reason); | 556 | smp_failure(conn, reason); |
548 | } | 557 | } |
549 | 558 | ||
550 | static void smp_reencrypt(struct work_struct *work) | ||
551 | { | ||
552 | struct smp_chan *smp = container_of(work, struct smp_chan, | ||
553 | reencrypt.work); | ||
554 | struct l2cap_conn *conn = smp->conn; | ||
555 | struct hci_conn *hcon = conn->hcon; | ||
556 | struct smp_ltk *ltk = smp->ltk; | ||
557 | |||
558 | BT_DBG(""); | ||
559 | |||
560 | hci_le_start_enc(hcon, ltk->ediv, ltk->rand, ltk->val); | ||
561 | hcon->enc_key_size = ltk->enc_size; | ||
562 | } | ||
563 | |||
564 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | 559 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) |
565 | { | 560 | { |
566 | struct smp_chan *smp; | 561 | struct smp_chan *smp; |
@@ -571,7 +566,6 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | |||
571 | 566 | ||
572 | INIT_WORK(&smp->confirm, confirm_work); | 567 | INIT_WORK(&smp->confirm, confirm_work); |
573 | INIT_WORK(&smp->random, random_work); | 568 | INIT_WORK(&smp->random, random_work); |
574 | INIT_DELAYED_WORK(&smp->reencrypt, smp_reencrypt); | ||
575 | 569 | ||
576 | smp->conn = conn; | 570 | smp->conn = conn; |
577 | conn->smp_chan = smp; | 571 | conn->smp_chan = smp; |
@@ -589,8 +583,6 @@ void smp_chan_destroy(struct l2cap_conn *conn) | |||
589 | 583 | ||
590 | BUG_ON(!smp); | 584 | BUG_ON(!smp); |
591 | 585 | ||
592 | cancel_delayed_work_sync(&smp->reencrypt); | ||
593 | |||
594 | complete = test_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); | 586 | complete = test_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); |
595 | mgmt_smp_complete(conn->hcon, complete); | 587 | mgmt_smp_complete(conn->hcon, complete); |
596 | 588 | ||
@@ -712,6 +704,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
712 | if (ret) | 704 | if (ret) |
713 | return SMP_UNSPECIFIED; | 705 | return SMP_UNSPECIFIED; |
714 | 706 | ||
707 | clear_bit(SMP_FLAG_INITIATOR, &smp->smp_flags); | ||
708 | |||
715 | return 0; | 709 | return 0; |
716 | } | 710 | } |
717 | 711 | ||
@@ -867,6 +861,8 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
867 | 861 | ||
868 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); | 862 | smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); |
869 | 863 | ||
864 | clear_bit(SMP_FLAG_INITIATOR, &smp->smp_flags); | ||
865 | |||
870 | return 0; | 866 | return 0; |
871 | } | 867 | } |
872 | 868 | ||
@@ -884,11 +880,15 @@ bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level) | |||
884 | int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | 880 | int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) |
885 | { | 881 | { |
886 | struct l2cap_conn *conn = hcon->l2cap_data; | 882 | struct l2cap_conn *conn = hcon->l2cap_data; |
887 | struct smp_chan *smp = conn->smp_chan; | 883 | struct smp_chan *smp; |
888 | __u8 authreq; | 884 | __u8 authreq; |
889 | 885 | ||
890 | BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); | 886 | BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); |
891 | 887 | ||
888 | /* This may be NULL if there's an unexpected disconnection */ | ||
889 | if (!conn) | ||
890 | return 1; | ||
891 | |||
892 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) | 892 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) |
893 | return 1; | 893 | return 1; |
894 | 894 | ||
@@ -928,6 +928,8 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
928 | smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); | 928 | smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); |
929 | } | 929 | } |
930 | 930 | ||
931 | set_bit(SMP_FLAG_INITIATOR, &smp->smp_flags); | ||
932 | |||
931 | done: | 933 | done: |
932 | hcon->pending_sec_level = sec_level; | 934 | hcon->pending_sec_level = sec_level; |
933 | 935 | ||
@@ -1058,12 +1060,6 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, | |||
1058 | smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, | 1060 | smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, |
1059 | smp->id_addr_type, smp->irk, &rpa); | 1061 | smp->id_addr_type, smp->irk, &rpa); |
1060 | 1062 | ||
1061 | /* Track the connection based on the Identity Address from now on */ | ||
1062 | bacpy(&hcon->dst, &smp->id_addr); | ||
1063 | hcon->dst_type = smp->id_addr_type; | ||
1064 | |||
1065 | l2cap_conn_update_id_addr(hcon); | ||
1066 | |||
1067 | smp_distribute_keys(conn); | 1063 | smp_distribute_keys(conn); |
1068 | 1064 | ||
1069 | return 0; | 1065 | return 0; |
@@ -1214,8 +1210,16 @@ static void smp_notify_keys(struct l2cap_conn *conn) | |||
1214 | struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; | 1210 | struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; |
1215 | bool persistent; | 1211 | bool persistent; |
1216 | 1212 | ||
1217 | if (smp->remote_irk) | 1213 | if (smp->remote_irk) { |
1218 | mgmt_new_irk(hdev, smp->remote_irk); | 1214 | mgmt_new_irk(hdev, smp->remote_irk); |
1215 | /* Now that user space can be considered to know the | ||
1216 | * identity address track the connection based on it | ||
1217 | * from now on. | ||
1218 | */ | ||
1219 | bacpy(&hcon->dst, &smp->remote_irk->bdaddr); | ||
1220 | hcon->dst_type = smp->remote_irk->addr_type; | ||
1221 | l2cap_conn_update_id_addr(hcon); | ||
1222 | } | ||
1219 | 1223 | ||
1220 | /* The LTKs and CSRKs should be persistent only if both sides | 1224 | /* The LTKs and CSRKs should be persistent only if both sides |
1221 | * had the bonding bit set in their authentication requests. | 1225 | * had the bonding bit set in their authentication requests. |
@@ -1253,7 +1257,6 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1253 | struct smp_chan *smp = conn->smp_chan; | 1257 | struct smp_chan *smp = conn->smp_chan; |
1254 | struct hci_conn *hcon = conn->hcon; | 1258 | struct hci_conn *hcon = conn->hcon; |
1255 | struct hci_dev *hdev = hcon->hdev; | 1259 | struct hci_dev *hdev = hcon->hdev; |
1256 | bool ltk_encrypt; | ||
1257 | __u8 *keydist; | 1260 | __u8 *keydist; |
1258 | 1261 | ||
1259 | BT_DBG("conn %p", conn); | 1262 | BT_DBG("conn %p", conn); |
@@ -1353,32 +1356,12 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1353 | if ((smp->remote_key_dist & 0x07)) | 1356 | if ((smp->remote_key_dist & 0x07)) |
1354 | return 0; | 1357 | return 0; |
1355 | 1358 | ||
1356 | /* Check if we should try to re-encrypt the link with the LTK. | 1359 | clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags); |
1357 | * SMP_FLAG_LTK_ENCRYPT flag is used to track whether we've | 1360 | cancel_delayed_work_sync(&conn->security_timer); |
1358 | * already tried this (in which case we shouldn't try again). | 1361 | set_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); |
1359 | * | 1362 | smp_notify_keys(conn); |
1360 | * The request will trigger an encryption key refresh event | ||
1361 | * which will cause a call to auth_cfm and eventually lead to | ||
1362 | * l2cap_core.c calling this smp_distribute_keys function again | ||
1363 | * and thereby completing the process. | ||
1364 | */ | ||
1365 | if (smp->ltk) | ||
1366 | ltk_encrypt = !test_and_set_bit(SMP_FLAG_LTK_ENCRYPT, | ||
1367 | &smp->smp_flags); | ||
1368 | else | ||
1369 | ltk_encrypt = false; | ||
1370 | 1363 | ||
1371 | /* Re-encrypt the link with LTK if possible */ | 1364 | smp_chan_destroy(conn); |
1372 | if (ltk_encrypt && hcon->out) { | ||
1373 | queue_delayed_work(hdev->req_workqueue, &smp->reencrypt, | ||
1374 | SMP_REENCRYPT_TIMEOUT); | ||
1375 | } else { | ||
1376 | clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags); | ||
1377 | cancel_delayed_work_sync(&conn->security_timer); | ||
1378 | set_bit(SMP_FLAG_COMPLETE, &smp->smp_flags); | ||
1379 | smp_notify_keys(conn); | ||
1380 | smp_chan_destroy(conn); | ||
1381 | } | ||
1382 | 1365 | ||
1383 | return 0; | 1366 | return 0; |
1384 | } | 1367 | } |
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h index b6913471815a..1277147a9150 100644 --- a/net/bluetooth/smp.h +++ b/net/bluetooth/smp.h | |||
@@ -118,10 +118,8 @@ struct smp_cmd_security_req { | |||
118 | #define SMP_FLAG_TK_VALID 1 | 118 | #define SMP_FLAG_TK_VALID 1 |
119 | #define SMP_FLAG_CFM_PENDING 2 | 119 | #define SMP_FLAG_CFM_PENDING 2 |
120 | #define SMP_FLAG_MITM_AUTH 3 | 120 | #define SMP_FLAG_MITM_AUTH 3 |
121 | #define SMP_FLAG_LTK_ENCRYPT 4 | 121 | #define SMP_FLAG_COMPLETE 4 |
122 | #define SMP_FLAG_COMPLETE 5 | 122 | #define SMP_FLAG_INITIATOR 5 |
123 | |||
124 | #define SMP_REENCRYPT_TIMEOUT msecs_to_jiffies(500) | ||
125 | 123 | ||
126 | struct smp_chan { | 124 | struct smp_chan { |
127 | struct l2cap_conn *conn; | 125 | struct l2cap_conn *conn; |
@@ -144,7 +142,6 @@ struct smp_chan { | |||
144 | unsigned long smp_flags; | 142 | unsigned long smp_flags; |
145 | struct work_struct confirm; | 143 | struct work_struct confirm; |
146 | struct work_struct random; | 144 | struct work_struct random; |
147 | struct delayed_work reencrypt; | ||
148 | }; | 145 | }; |
149 | 146 | ||
150 | /* SMP Commands */ | 147 | /* SMP Commands */ |