All of lore.kernel.org
 help / color / mirror / Atom feed
From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 3/9] Bluetooth: Resume BT_CONNECTED state after LE security elevation
Date: Thu,  7 Aug 2014 10:12:25 +0300	[thread overview]
Message-ID: <1407395551-30810-4-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1407395551-30810-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

The LE ATT socket uses a special trick where it temporarily sets
BT_CONFIG state for the duration of a security level elevation. In order
to not require special hacks for going back to BT_CONNECTED state in the
l2cap_core.c code the most reasonable place to resume the state is the
resume callback. This patch adds a new flag to track the pending
security level change and ensures that the state is set back to
BT_CONNECTED in the resume callback in case the flag is set.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/l2cap.h | 1 +
 net/bluetooth/l2cap_sock.c    | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 8df15ad0d43f..4a51e7596608 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -708,6 +708,7 @@ enum {
 	FLAG_EFS_ENABLE,
 	FLAG_DEFER_SETUP,
 	FLAG_LE_CONN_REQ_SENT,
+	FLAG_PENDING_SECURITY,
 };
 
 enum {
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1884f72083c2..5a42f6a818c0 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -790,6 +790,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
 		if (chan->scid == L2CAP_CID_ATT) {
 			if (smp_conn_security(conn->hcon, sec.level))
 				break;
+			set_bit(FLAG_PENDING_SECURITY, &chan->flags);
 			sk->sk_state = BT_CONFIG;
 			chan->state = BT_CONFIG;
 
@@ -1359,6 +1360,11 @@ static void l2cap_sock_resume_cb(struct l2cap_chan *chan)
 {
 	struct sock *sk = chan->data;
 
+	if (test_and_clear_bit(FLAG_PENDING_SECURITY, &chan->flags)) {
+		sk->sk_state = BT_CONNECTED;
+		chan->state = BT_CONNECTED;
+	}
+
 	clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
 	sk->sk_state_change(sk);
 }
-- 
1.9.3


  parent reply	other threads:[~2014-08-07  7:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07  7:12 [PATCH 0/9] Bluetooth: More generic L2CAP fixed channel handling johan.hedberg
2014-08-07  7:12 ` [PATCH 1/9] Bluetooth: Fix reference counting of global L2CAP channels johan.hedberg
2014-08-07 16:26   ` Marcel Holtmann
2014-08-07  7:12 ` [PATCH 2/9] Bluetooth: Fix __l2cap_no_conn_pending() usage with all channels johan.hedberg
2014-08-07  7:12 ` johan.hedberg [this message]
2014-08-07  7:12 ` [PATCH 4/9] Bluetooth: Remove special handling of ATT in l2cap_security_cfm() johan.hedberg
2014-08-07  7:12 ` [PATCH 5/9] Bluetooth: Refactor l2cap_connect_cfm johan.hedberg
2014-08-07  7:12 ` [PATCH 6/9] Bluetooth: Move L2CAP fixed channel creation into l2cap_conn_cfm johan.hedberg
2014-08-07  7:12 ` [PATCH 7/9] Bluetooth: Improve fixed channel lookup based on link type johan.hedberg
2014-08-07  7:12 ` [PATCH 8/9] Bluetooth: Remove special ATT data channel handling johan.hedberg
2014-08-07  7:12 ` [PATCH 9/9] Bluetooth: Move parts of fixed channel initialization to l2cap_add_scid johan.hedberg
2014-08-08 17:43 ` [PATCH 0/9] Bluetooth: More generic L2CAP fixed channel handling Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407395551-30810-4-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.