* [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-19 9:42 [PATCH 0/3] New versions of some previous mgmt patches johan.hedberg
@ 2012-01-19 9:42 ` johan.hedberg
2012-01-19 10:04 ` Marcel Holtmann
2012-01-19 11:38 ` Anderson Lizardo
2012-01-19 9:42 ` [PATCH 2/3] Bluetooth Convert hdev->ssp_mode to a flag johan.hedberg
2012-01-19 9:42 ` [PATCH 3/3] Bluetooth: Add a convenience function to check for SSP enabled johan.hedberg
2 siblings, 2 replies; 8+ messages in thread
From: johan.hedberg @ 2012-01-19 9:42 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Now that the flags member of struct hci_conn is supposed to accommodate
any boolean type values we can easily merge all boolean members into it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 6 +++---
net/bluetooth/hci_conn.c | 15 +++++++++------
net/bluetooth/hci_event.c | 21 +++++++++++++--------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 18af542..7a03311 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -286,7 +286,6 @@ struct hci_conn {
__u8 attempt;
__u8 dev_class[3];
__u8 features[8];
- __u8 ssp_mode;
__u16 interval;
__u16 pkt_type;
__u16 link_policy;
@@ -298,12 +297,10 @@ struct hci_conn {
__u8 pin_length;
__u8 enc_key_size;
__u8 io_capability;
- __u8 power_save;
__u16 disc_timeout;
unsigned long flags;
__u8 remote_cap;
- __u8 remote_oob;
__u8 remote_auth;
unsigned int sent;
@@ -410,6 +407,9 @@ enum {
HCI_CONN_SCO_SETUP_PEND,
HCI_CONN_LE_SMP_PEND,
HCI_CONN_MGMT_CONNECTED,
+ HCI_CONN_SSP_ENABLED,
+ HCI_CONN_POWER_SAVE,
+ HCI_CONN_REMOTE_OOB,
};
static inline void hci_conn_hash_init(struct hci_dev *hdev)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index a707d19..8288e30 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -105,7 +105,8 @@ void hci_acl_connect(struct hci_conn *conn)
}
memcpy(conn->dev_class, ie->data.dev_class, 3);
- conn->ssp_mode = ie->data.ssp_mode;
+ if (ie->data.ssp_mode > 0)
+ set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
}
cp.pkt_type = cpu_to_le16(conn->pkt_type);
@@ -386,7 +387,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
conn->remote_auth = 0xff;
conn->key_type = 0xff;
- conn->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
switch (type) {
@@ -586,7 +587,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
if (acl->state == BT_CONNECTED &&
(sco->state == BT_OPEN || sco->state == BT_CLOSED)) {
- acl->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &acl->flags);
hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON);
if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->flags)) {
@@ -607,7 +608,8 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 &&
+ if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
+ conn->hdev->ssp_mode > 0 &&
!(conn->link_mode & HCI_LM_ENCRYPT))
return 0;
@@ -671,7 +673,8 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
/* For non 2.1 devices and low security level we don't need the link
key. */
if (sec_level == BT_SECURITY_LOW &&
- (!conn->ssp_mode || !conn->hdev->ssp_mode))
+ (!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) ||
+ !conn->hdev->ssp_mode))
return 1;
/* For other security levels we need the link key. */
@@ -778,7 +781,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
if (conn->mode != HCI_CM_SNIFF)
goto timer;
- if (!conn->power_save && !force_active)
+ if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active)
goto timer;
if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 22d1455..cbb0fa2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1264,7 +1264,8 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
/* Only request authentication for SSP connections or non-SSP
* devices with sec_level HIGH or if MITM protection is requested */
- if (!(hdev->ssp_mode > 0 && conn->ssp_mode > 0) &&
+ if (!(hdev->ssp_mode > 0 &&
+ test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) &&
conn->pending_sec_level != BT_SECURITY_HIGH &&
!(conn->auth_type & 0x01))
return 0;
@@ -1838,7 +1839,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
if (!ev->status) {
- if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
+ if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
+ hdev->ssp_mode > 0) &&
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
@@ -1853,7 +1855,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
- if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) {
+ if (!ev->status && hdev->ssp_mode > 0 &&
+ test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
@@ -2505,9 +2508,9 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
if (conn->mode == HCI_CM_ACTIVE)
- conn->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
else
- conn->power_save = 0;
+ clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
}
if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
@@ -2780,7 +2783,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
if (ie)
ie->data.ssp_mode = (ev->features[0] & 0x01);
- conn->ssp_mode = (ev->features[0] & 0x01);
+ if (ev->features[0] & 0x01)
+ set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
}
if (conn->state != BT_CONFIG)
@@ -2962,7 +2966,7 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
conn->auth_type = hci_get_auth_req(conn);
cp.authentication = conn->auth_type;
- if ((conn->out == 0x01 || conn->remote_oob == 0x01) &&
+ if ((conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)) &&
hci_find_remote_oob_data(hdev, &conn->dst))
cp.oob_data = 0x01;
else
@@ -2998,8 +3002,9 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
conn->remote_cap = ev->capability;
- conn->remote_oob = ev->oob_data;
conn->remote_auth = ev->authentication;
+ if (ev->oob_data)
+ set_bit(HCI_CONN_REMOTE_OOB, &conn->flags);
unlock:
hci_dev_unlock(hdev);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-19 9:42 ` [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags johan.hedberg
@ 2012-01-19 10:04 ` Marcel Holtmann
2012-01-19 11:38 ` Anderson Lizardo
1 sibling, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-01-19 10:04 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> Now that the flags member of struct hci_conn is supposed to accommodate
> any boolean type values we can easily merge all boolean members into it.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 6 +++---
> net/bluetooth/hci_conn.c | 15 +++++++++------
> net/bluetooth/hci_event.c | 21 +++++++++++++--------
> 3 files changed, 25 insertions(+), 17 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-19 9:42 ` [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags johan.hedberg
2012-01-19 10:04 ` Marcel Holtmann
@ 2012-01-19 11:38 ` Anderson Lizardo
1 sibling, 0 replies; 8+ messages in thread
From: Anderson Lizardo @ 2012-01-19 11:38 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
Not sure if this is actually a bug, but mentioning anyway.
On Thu, Jan 19, 2012 at 5:42 AM, <johan.hedberg@gmail.com> wrote:
> @@ -105,7 +105,8 @@ void hci_acl_connect(struct hci_conn *conn)
> }
>
> memcpy(conn->dev_class, ie->data.dev_class, 3);
> - conn->ssp_mode = ie->data.ssp_mode;
> + if (ie->data.ssp_mode > 0)
> + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
> }
Note that the code above is not semantically equivalent to the old
one. Given "conn" was not created on this function, the old code was
actually equivalent to:
if (ie->data.ssp_mode)
conn->ssp_mode = 1;
else
conn->ssp_mode = 0;
So I think you need set_bit/clear_bit branches here.
>
> cp.pkt_type = cpu_to_le16(conn->pkt_type);
> [...]
> @@ -2780,7 +2783,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
> if (ie)
> ie->data.ssp_mode = (ev->features[0] & 0x01);
>
> - conn->ssp_mode = (ev->features[0] & 0x01);
> + if (ev->features[0] & 0x01)
> + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
> }
Same here.
>
> if (conn->state != BT_CONFIG)
> [...]
> @@ -2998,8 +3002,9 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s
> goto unlock;
>
> conn->remote_cap = ev->capability;
> - conn->remote_oob = ev->oob_data;
> conn->remote_auth = ev->authentication;
> + if (ev->oob_data)
> + set_bit(HCI_CONN_REMOTE_OOB, &conn->flags);
Same here.
>
> unlock:
> hci_dev_unlock(hdev);
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] Bluetooth Convert hdev->ssp_mode to a flag
2012-01-19 9:42 [PATCH 0/3] New versions of some previous mgmt patches johan.hedberg
2012-01-19 9:42 ` [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags johan.hedberg
@ 2012-01-19 9:42 ` johan.hedberg
2012-01-19 10:03 ` Marcel Holtmann
2012-01-19 9:42 ` [PATCH 3/3] Bluetooth: Add a convenience function to check for SSP enabled johan.hedberg
2 siblings, 1 reply; 8+ messages in thread
From: johan.hedberg @ 2012-01-19 9:42 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The ssp_mode is essentially just a boolean so it's more appropriate to
have it simply as a flag in hdev->dev_flags.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 1 +
include/net/bluetooth/hci_core.h | 1 -
net/bluetooth/hci_conn.c | 6 +++---
net/bluetooth/hci_event.c | 17 ++++++++++++-----
net/bluetooth/mgmt.c | 4 ++--
5 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index dd2cc6c..cb9097a 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -94,6 +94,7 @@ enum {
HCI_DEBUG_KEYS,
HCI_LE_SCAN,
+ HCI_SSP_ENABLED,
};
/* HCI ioctl defines */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7a03311..94ba869 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -144,7 +144,6 @@ struct hci_dev {
__u8 features[8];
__u8 host_features[8];
__u8 commands[64];
- __u8 ssp_mode;
__u8 hci_ver;
__u16 hci_rev;
__u8 lmp_ver;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 8288e30..6ec259e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -609,8 +609,8 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
BT_DBG("conn %p", conn);
if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
- conn->hdev->ssp_mode > 0 &&
- !(conn->link_mode & HCI_LM_ENCRYPT))
+ test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags) &&
+ !(conn->link_mode & HCI_LM_ENCRYPT))
return 0;
return 1;
@@ -674,7 +674,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
key. */
if (sec_level == BT_SECURITY_LOW &&
(!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) ||
- !conn->hdev->ssp_mode))
+ !test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags)))
return 1;
/* For other security levels we need the link key. */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index cbb0fa2..3163d18 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -429,7 +429,10 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
if (rp->status)
return;
- hdev->ssp_mode = rp->mode;
+ if (rp->mode)
+ set_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
}
static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -446,7 +449,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
if (!sent)
return;
- hdev->ssp_mode = *((__u8 *) sent);
+ if (*((u8 *) sent))
+ set_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
}
static u8 hci_get_inquiry_mode(struct hci_dev *hdev)
@@ -1264,7 +1270,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
/* Only request authentication for SSP connections or non-SSP
* devices with sec_level HIGH or if MITM protection is requested */
- if (!(hdev->ssp_mode > 0 &&
+ if (!(test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) &&
conn->pending_sec_level != BT_SECURITY_HIGH &&
!(conn->auth_type & 0x01))
@@ -1840,7 +1846,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (!ev->status) {
if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
- hdev->ssp_mode > 0) &&
+ test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) &&
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
@@ -1855,7 +1861,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
- if (!ev->status && hdev->ssp_mode > 0 &&
+ if (!ev->status &&
+ test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ae9283d..8970799 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -297,7 +297,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_AUTH, &hdev->flags))
settings |= MGMT_SETTING_LINK_SECURITY;
- if (hdev->ssp_mode > 0)
+ if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
settings |= MGMT_SETTING_SSP;
return settings;
@@ -416,7 +416,7 @@ static int update_eir(struct hci_dev *hdev)
if (!(hdev->features[6] & LMP_EXT_INQ))
return 0;
- if (hdev->ssp_mode == 0)
+ if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
return 0;
if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
--
1.7.8.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] Bluetooth Convert hdev->ssp_mode to a flag
2012-01-19 9:42 ` [PATCH 2/3] Bluetooth Convert hdev->ssp_mode to a flag johan.hedberg
@ 2012-01-19 10:03 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-01-19 10:03 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> The ssp_mode is essentially just a boolean so it's more appropriate to
> have it simply as a flag in hdev->dev_flags.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 1 +
> include/net/bluetooth/hci_core.h | 1 -
> net/bluetooth/hci_conn.c | 6 +++---
> net/bluetooth/hci_event.c | 17 ++++++++++++-----
> net/bluetooth/mgmt.c | 4 ++--
> 5 files changed, 18 insertions(+), 11 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] Bluetooth: Add a convenience function to check for SSP enabled
2012-01-19 9:42 [PATCH 0/3] New versions of some previous mgmt patches johan.hedberg
2012-01-19 9:42 ` [PATCH 1/3] Bluetooth: Merge boolean members of struct hci_conn into flags johan.hedberg
2012-01-19 9:42 ` [PATCH 2/3] Bluetooth Convert hdev->ssp_mode to a flag johan.hedberg
@ 2012-01-19 9:42 ` johan.hedberg
2012-01-19 10:03 ` Marcel Holtmann
2 siblings, 1 reply; 8+ messages in thread
From: johan.hedberg @ 2012-01-19 9:42 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
It's a very common test to see if both the local and the remote device
have SSP enabled. By creating a simple function to test this we can
shorten many if-statements in the code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 7 +++++++
net/bluetooth/hci_conn.c | 8 ++------
net/bluetooth/hci_event.c | 12 ++++--------
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 94ba869..25f449f 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -411,6 +411,13 @@ enum {
HCI_CONN_REMOTE_OOB,
};
+static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
+{
+ struct hci_dev *hdev = conn->hdev;
+ return (test_bit(HCI_SSP_ENABLED, &hdev->flags) &&
+ test_bit(HCI_CONN_SSP_ENABLED, &conn->flags));
+}
+
static inline void hci_conn_hash_init(struct hci_dev *hdev)
{
struct hci_conn_hash *h = &hdev->conn_hash;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 6ec259e..eae7a53 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -608,9 +608,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
- test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags) &&
- !(conn->link_mode & HCI_LM_ENCRYPT))
+ if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT))
return 0;
return 1;
@@ -672,9 +670,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
/* For non 2.1 devices and low security level we don't need the link
key. */
- if (sec_level == BT_SECURITY_LOW &&
- (!test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) ||
- !test_bit(HCI_SSP_ENABLED, &conn->hdev->dev_flags)))
+ if (sec_level == BT_SECURITY_LOW && !hci_conn_ssp_enabled(conn))
return 1;
/* For other security levels we need the link key. */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 3163d18..b24c663 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1270,8 +1270,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
/* Only request authentication for SSP connections or non-SSP
* devices with sec_level HIGH or if MITM protection is requested */
- if (!(test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
- test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) &&
+ if (!hci_conn_ssp_enabled(conn) &&
conn->pending_sec_level != BT_SECURITY_HIGH &&
!(conn->auth_type & 0x01))
return 0;
@@ -1845,9 +1844,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
if (!ev->status) {
- if (!(test_bit(HCI_CONN_SSP_ENABLED, &conn->flags) &&
- test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) &&
- test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
+ if (!hci_conn_ssp_enabled(conn) &&
+ test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
conn->link_mode |= HCI_LM_AUTH;
@@ -1861,9 +1859,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
- if (!ev->status &&
- test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
- test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)) {
+ if (!ev->status && hci_conn_ssp_enabled(conn)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 8+ messages in thread