Re: [v4.4/bluetooth PATCH 1/3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
On Fri, Oct 16, 2020 at 07:46:39AM +, Hans-Christian Egtvedt (hegtvedt) wrote: > On 16/10/2020 09:32, Greg KH wrote: > > On Thu, Oct 15, 2020 at 11:12:23PM +0200, Hans-Christian Noren Egtvedt > > wrote: > >> From: Luiz Augusto von Dentz > >> > >> This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection > >> state is BT_CONFIG so callers don't have to check the state. > >> > >> Signed-off-by: Luiz Augusto von Dentz > >> Signed-off-by: Marcel Holtmann > >> (cherry picked from commit 3ca44c16b0dcc764b641ee4ac226909f5c421aa3) > >> Cc: sta...@vger.kernel.org # 4.4 > >> --- > >> include/net/bluetooth/hci_core.h | 20 ++-- > >> net/bluetooth/hci_event.c| 28 +++- > >> 2 files changed, 21 insertions(+), 27 deletions(-) > > > > What differs here from the other patch series you sent? Looks the same > > to me... > > Patch 1 and 2 in this series is identical, patch 3/3 is adjusted to > resolve a conflict. Sorry I did not make that clearer. No problem, thanks for confirming this, that makes me feel better that I didn't miss anything. greg k-h
Re: [v4.4/bluetooth PATCH 1/3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
On 16/10/2020 09:32, Greg KH wrote: > On Thu, Oct 15, 2020 at 11:12:23PM +0200, Hans-Christian Noren Egtvedt wrote: >> From: Luiz Augusto von Dentz >> >> This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection >> state is BT_CONFIG so callers don't have to check the state. >> >> Signed-off-by: Luiz Augusto von Dentz >> Signed-off-by: Marcel Holtmann >> (cherry picked from commit 3ca44c16b0dcc764b641ee4ac226909f5c421aa3) >> Cc: sta...@vger.kernel.org # 4.4 >> --- >> include/net/bluetooth/hci_core.h | 20 ++-- >> net/bluetooth/hci_event.c| 28 +++- >> 2 files changed, 21 insertions(+), 27 deletions(-) > > What differs here from the other patch series you sent? Looks the same > to me... Patch 1 and 2 in this series is identical, patch 3/3 is adjusted to resolve a conflict. Sorry I did not make that clearer. -- Best regards, Hans-Christian Noren Egtvedt pEpkey.asc Description: pEpkey.asc
Re: [v4.4/bluetooth PATCH 1/3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
On Thu, Oct 15, 2020 at 11:12:23PM +0200, Hans-Christian Noren Egtvedt wrote: > From: Luiz Augusto von Dentz > > This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection > state is BT_CONFIG so callers don't have to check the state. > > Signed-off-by: Luiz Augusto von Dentz > Signed-off-by: Marcel Holtmann > (cherry picked from commit 3ca44c16b0dcc764b641ee4ac226909f5c421aa3) > Cc: sta...@vger.kernel.org # 4.4 > --- > include/net/bluetooth/hci_core.h | 20 ++-- > net/bluetooth/hci_event.c| 28 +++- > 2 files changed, 21 insertions(+), 27 deletions(-) What differs here from the other patch series you sent? Looks the same to me...
[v4.4/bluetooth PATCH 1/3] Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
From: Luiz Augusto von Dentz This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection state is BT_CONFIG so callers don't have to check the state. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann (cherry picked from commit 3ca44c16b0dcc764b641ee4ac226909f5c421aa3) Cc: sta...@vger.kernel.org # 4.4 --- include/net/bluetooth/hci_core.h | 20 ++-- net/bluetooth/hci_event.c| 28 +++- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7c0c83dfe86e..0269a772bfe1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1235,10 +1235,26 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) conn->security_cfm_cb(conn, status); } -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, - __u8 encrypt) +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) { struct hci_cb *cb; + __u8 encrypt; + + if (conn->state == BT_CONFIG) { + if (status) + conn->state = BT_CONNECTED; + + hci_connect_cfm(conn, status); + hci_conn_drop(conn); + return; + } + + if (!test_bit(HCI_CONN_ENCRYPT, >flags)) + encrypt = 0x00; + else if (test_bit(HCI_CONN_AES_CCM, >flags)) + encrypt = 0x02; + else + encrypt = 0x01; if (conn->sec_level == BT_SECURITY_SDP) conn->sec_level = BT_SECURITY_LOW; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 03319ab8a7c6..bb9c13506bca 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2479,7 +2479,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) ); } else { clear_bit(HCI_CONN_ENCRYPT_PEND, >flags); - hci_encrypt_cfm(conn, ev->status, 0x00); + hci_encrypt_cfm(conn, ev->status); } } @@ -2565,22 +2565,7 @@ static void read_enc_key_size_complete(struct hci_dev *hdev, u8 status, conn->enc_key_size = rp->key_size; } - if (conn->state == BT_CONFIG) { - conn->state = BT_CONNECTED; - hci_connect_cfm(conn, 0); - hci_conn_drop(conn); - } else { - u8 encrypt; - - if (!test_bit(HCI_CONN_ENCRYPT, >flags)) - encrypt = 0x00; - else if (test_bit(HCI_CONN_AES_CCM, >flags)) - encrypt = 0x02; - else - encrypt = 0x01; - - hci_encrypt_cfm(conn, 0, encrypt); - } + hci_encrypt_cfm(conn, 0); unlock: hci_dev_unlock(hdev); @@ -2674,14 +2659,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) } notify: - if (conn->state == BT_CONFIG) { - if (!ev->status) - conn->state = BT_CONNECTED; - - hci_connect_cfm(conn, ev->status); - hci_conn_drop(conn); - } else - hci_encrypt_cfm(conn, ev->status, ev->encrypt); + hci_encrypt_cfm(conn, ev->status); unlock: hci_dev_unlock(hdev); -- 2.27.0