Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 134721
b: refs/heads/master
c: f62e432
h: refs/heads/master
i:
  134719: eb4263d
v: v3
  • Loading branch information
Marcel Holtmann committed Feb 27, 2009
1 parent 0a8f229 commit ec022f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c84b83076b5062f59b6167cdda90d9e5124aa71
refs/heads/master: f62e4323ab43c59e7cd7f72c1eb392d7c767ce5a
26 changes: 19 additions & 7 deletions trunk/net/bluetooth/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ static void l2cap_sock_timeout(unsigned long arg)

bh_lock_sock(sk);

if (sk->sk_state == BT_CONNECT &&
if (sk->sk_state == BT_CONNECTED || sk->sk_state == BT_CONFIG)
reason = ECONNREFUSED;
else if (sk->sk_state == BT_CONNECT &&
l2cap_pi(sk)->sec_level != BT_SECURITY_SDP)
reason = ECONNREFUSED;
else
Expand Down Expand Up @@ -2400,6 +2402,20 @@ static int l2cap_disconn_ind(struct hci_conn *hcon, u8 reason)
return 0;
}

static inline void l2cap_check_encryption(struct sock *sk, u8 encrypt)
{
if (encrypt == 0x00) {
if (l2cap_pi(sk)->sec_level == BT_SECURITY_MEDIUM) {
l2cap_sock_clear_timer(sk);
l2cap_sock_set_timer(sk, HZ * 5);
} else if (l2cap_pi(sk)->sec_level == BT_SECURITY_HIGH)
__l2cap_sock_close(sk, ECONNREFUSED);
} else {
if (l2cap_pi(sk)->sec_level == BT_SECURITY_MEDIUM)
l2cap_sock_clear_timer(sk);
}
}

static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
{
struct l2cap_chan_list *l;
Expand All @@ -2416,15 +2432,11 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
read_lock(&l->lock);

for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) {
struct l2cap_pinfo *pi = l2cap_pi(sk);

bh_lock_sock(sk);

if (!status && encrypt == 0x00 &&
pi->sec_level == BT_SECURITY_HIGH &&
(sk->sk_state == BT_CONNECTED ||
if (!status && (sk->sk_state == BT_CONNECTED ||
sk->sk_state == BT_CONFIG)) {
__l2cap_sock_close(sk, ECONNREFUSED);
l2cap_check_encryption(sk, encrypt);
bh_unlock_sock(sk);
continue;
}
Expand Down

0 comments on commit ec022f8

Please sign in to comment.