linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] A few more cleanups for l2cap_chan based SMP
@ 2014-08-08  6:28 johan.hedberg
  2014-08-08  6:28 ` [PATCH 1/3] Bluetooth: Call L2CAP teardown callback before clearing chan->conn johan.hedberg
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: johan.hedberg @ 2014-08-08  6:28 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

Here are a few more cleanups/fixes in preparation for converting SMP to
use l2cap_chan.

Johan

----------------------------------------------------------------
Johan Hedberg (3):
      Bluetooth: Call L2CAP teardown callback before clearing chan->conn
      Bluetooth: Call l2cap_le_conn_ready after notifying channels
      Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context

 net/bluetooth/l2cap_core.c | 10 +++++-----
 net/bluetooth/smp.c        |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] Bluetooth: Call L2CAP teardown callback before clearing chan->conn
  2014-08-08  6:28 [PATCH 0/3] A few more cleanups for l2cap_chan based SMP johan.hedberg
@ 2014-08-08  6:28 ` johan.hedberg
  2014-08-08  6:28 ` [PATCH 2/3] Bluetooth: Call l2cap_le_conn_ready after notifying channels johan.hedberg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: johan.hedberg @ 2014-08-08  6:28 UTC (permalink / raw)
  To: linux-bluetooth

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

L2CAP channel implementations may want to still access the chan->conn
pointer. This will particularly be the case for SMP that will want to
clear a reference to the SMP channel in the l2cap_conn structure. The
only user of the teardown callback so far is l2cap_sock.c and for the
code there it makes no difference whether the callback is called before
or after clearing the chan->conn pointer.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 344a29c53227..c6419f40cfba 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -566,6 +566,8 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 
 	BT_DBG("chan %p, conn %p, err %d", chan, conn, err);
 
+	chan->ops->teardown(chan, err);
+
 	if (conn) {
 		struct amp_mgr *mgr = conn->hcon->amp_mgr;
 		/* Delete from channel list */
@@ -589,8 +591,6 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 		amp_disconnect_logical_link(hs_hchan);
 	}
 
-	chan->ops->teardown(chan, err);
-
 	if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
 		return;
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Bluetooth: Call l2cap_le_conn_ready after notifying channels
  2014-08-08  6:28 [PATCH 0/3] A few more cleanups for l2cap_chan based SMP johan.hedberg
  2014-08-08  6:28 ` [PATCH 1/3] Bluetooth: Call L2CAP teardown callback before clearing chan->conn johan.hedberg
@ 2014-08-08  6:28 ` johan.hedberg
  2014-08-08  6:28 ` [PATCH 3/3] Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context johan.hedberg
  2014-08-08 17:47 ` [PATCH 0/3] A few more cleanups for l2cap_chan based SMP Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: johan.hedberg @ 2014-08-08  6:28 UTC (permalink / raw)
  To: linux-bluetooth

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

For most cases it makes no difference whether l2cap_le_conn_ready() is
called before or after calling the channel ready() callbacks, however
for upcoming SMP code we need this as the ready() callback initializes
certain structures that a call to smp_conn_security() from
l2cap_le_conn_ready() depends on. Therefore, move the call to
l2cap_le_conn_ready() after iterating through and notifying channels.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/l2cap_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c6419f40cfba..8acfe6f57b5e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1464,9 +1464,6 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
 
 	BT_DBG("conn %p", conn);
 
-	if (hcon->type == LE_LINK)
-		l2cap_le_conn_ready(conn);
-
 	mutex_lock(&conn->chan_lock);
 
 	list_for_each_entry(chan, &conn->chan_l, list) {
@@ -1492,6 +1489,9 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
 
 	mutex_unlock(&conn->chan_lock);
 
+	if (hcon->type == LE_LINK)
+		l2cap_le_conn_ready(conn);
+
 	queue_work(hcon->hdev->workqueue, &conn->pending_rx_work);
 }
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context
  2014-08-08  6:28 [PATCH 0/3] A few more cleanups for l2cap_chan based SMP johan.hedberg
  2014-08-08  6:28 ` [PATCH 1/3] Bluetooth: Call L2CAP teardown callback before clearing chan->conn johan.hedberg
  2014-08-08  6:28 ` [PATCH 2/3] Bluetooth: Call l2cap_le_conn_ready after notifying channels johan.hedberg
@ 2014-08-08  6:28 ` johan.hedberg
  2014-08-08 17:47 ` [PATCH 0/3] A few more cleanups for l2cap_chan based SMP Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: johan.hedberg @ 2014-08-08  6:28 UTC (permalink / raw)
  To: linux-bluetooth

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

The code is consistently using the HCI_CONN_LE_SMP_PEND flag check for
the existence of the SMP context, with the exception of this one place
in smp_sig_channel(). This patch converts the place to use the flag just
like all other instances.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 40db728f044b..33016ec9b247 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1206,7 +1206,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
 	 * returns an error).
 	 */
 	if (code != SMP_CMD_PAIRING_REQ && code != SMP_CMD_SECURITY_REQ &&
-	    !conn->smp_chan) {
+	    !test_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) {
 		BT_ERR("Unexpected SMP command 0x%02x. Disconnecting.", code);
 		kfree_skb(skb);
 		return -EOPNOTSUPP;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] A few more cleanups for l2cap_chan based SMP
  2014-08-08  6:28 [PATCH 0/3] A few more cleanups for l2cap_chan based SMP johan.hedberg
                   ` (2 preceding siblings ...)
  2014-08-08  6:28 ` [PATCH 3/3] Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context johan.hedberg
@ 2014-08-08 17:47 ` Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2014-08-08 17:47 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth

Hi Johan,

> Here are a few more cleanups/fixes in preparation for converting SMP to
> use l2cap_chan.
> 
> Johan
> 
> ----------------------------------------------------------------
> Johan Hedberg (3):
>      Bluetooth: Call L2CAP teardown callback before clearing chan->conn
>      Bluetooth: Call l2cap_le_conn_ready after notifying channels
>      Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context
> 
> net/bluetooth/l2cap_core.c | 10 +++++-----
> net/bluetooth/smp.c        |  2 +-
> 2 files changed, 6 insertions(+), 6 deletions(-)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-08 17:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-08  6:28 [PATCH 0/3] A few more cleanups for l2cap_chan based SMP johan.hedberg
2014-08-08  6:28 ` [PATCH 1/3] Bluetooth: Call L2CAP teardown callback before clearing chan->conn johan.hedberg
2014-08-08  6:28 ` [PATCH 2/3] Bluetooth: Call l2cap_le_conn_ready after notifying channels johan.hedberg
2014-08-08  6:28 ` [PATCH 3/3] Bluetooth: Fix using HCI_CONN_LE_SMP_PEND to check for SMP context johan.hedberg
2014-08-08 17:47 ` [PATCH 0/3] A few more cleanups for l2cap_chan based SMP Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).