From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 13/13] Bluetooth: Fix multiple LE socket handling
Date: Mon, 29 Apr 2013 19:35:45 +0300 [thread overview]
Message-ID: <1367253345-12482-14-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1367253345-12482-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The LE ATT server socket needs to be superseded by any ATT client
sockets. Previously this was done by looking at the hcon->out variable
(indicating whether the connection is outgoing or incoming) which is a
too crude way of determining whether the server socket needs to be
picked or not (an outgoing connection doesn't necessarily mean that an
ATT client socket has triggered it).
This patch extends the ATT server socket lookup function
(l2cap_le_conn_ready) to be used for all LE connections (regardless of
the hcon->out value) and adds an internal check into the function for
the existence of any ATT client sockets (in which case the server socket
should be skipped). For this to work reliably all lookups must be done
while the l2cap_conn->chan_lock is held, meaning also that the call to
l2cap_chan_add needs to be changed to its lockless __l2cap_chan_add
counterpart.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/l2cap_core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d510550..05e6255 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1353,6 +1353,10 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
if (!pchan)
return;
+ /* Client ATT sockets should override the server one */
+ if (__l2cap_get_chan_by_dcid(conn, L2CAP_CID_ATT))
+ return;
+
parent = pchan->sk;
lock_sock(parent);
@@ -1366,7 +1370,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
bacpy(&bt_sk(chan->sk)->src, conn->src);
bacpy(&bt_sk(chan->sk)->dst, conn->dst);
- l2cap_chan_add(conn, chan);
+ __l2cap_chan_add(conn, chan);
clean:
release_sock(parent);
@@ -1379,9 +1383,6 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
BT_DBG("conn %p", conn);
- if (!hcon->out && hcon->type == LE_LINK)
- l2cap_le_conn_ready(conn);
-
/* For outgoing pairing which doesn't necessarily have an
* associated socket (e.g. mgmt_pair_device).
*/
@@ -1390,6 +1391,9 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
mutex_lock(&conn->chan_lock);
+ if (hcon->type == LE_LINK)
+ l2cap_le_conn_ready(conn);
+
list_for_each_entry(chan, &conn->chan_l, list) {
l2cap_chan_lock(chan);
--
1.7.10.4
next prev parent reply other threads:[~2013-04-29 16:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-29 16:35 [PATCH 00/13] Bluetooth: L2CAP cleanups and fixes Johan Hedberg
2013-04-29 16:35 ` [PATCH 01/13] Bluetooth: Handle LE L2CAP signalling in its own function Johan Hedberg
2013-04-29 16:35 ` [PATCH 02/13] Bluetooth: Create independent LE signalling defines and structs Johan Hedberg
2013-04-29 16:35 ` [PATCH 03/13] Bluetooth: Rename L2CAP_CID_LE_DATA to L2CAP_CID_ATT Johan Hedberg
2013-04-29 16:35 ` [PATCH 04/13] Bluetooth: Fix LE vs BR/EDR selection when connecting Johan Hedberg
2013-04-30 17:36 ` Vinicius Costa Gomes
2013-04-30 17:51 ` Marcel Holtmann
2013-04-30 18:33 ` Vinicius Costa Gomes
2013-04-30 17:53 ` Johan Hedberg
2013-04-29 16:35 ` [PATCH 05/13] Bluetooth: Fix EBUSY condition test in l2cap_chan_connect Johan Hedberg
2013-04-29 16:35 ` [PATCH 06/13] Bluetooth: Fix hardcoding ATT CID in __l2cap_chan_add() Johan Hedberg
2013-04-29 16:35 ` [PATCH 07/13] Bluetooth: Add clarifying comment to l2cap_conn_ready() Johan Hedberg
2013-04-29 16:35 ` [PATCH 08/13] Bluetooth: Fix duplicate call to l2cap_chan_ready() Johan Hedberg
2013-04-29 16:35 ` [PATCH 09/13] Bluetooth: Remove useless sk variable in l2cap_le_conn_ready Johan Hedberg
2013-04-29 16:35 ` [PATCH 10/13] Bluetooth: Remove unnecessary L2CAP channel state check Johan Hedberg
2013-04-29 16:35 ` [PATCH 11/13] Bluetooth: Simplify hci_conn_hold/drop logic for L2CAP Johan Hedberg
2013-04-29 16:35 ` [PATCH 12/13] Bluetooth: Remove useless hci_conn disc_timeout setting Johan Hedberg
2013-04-29 16:35 ` Johan Hedberg [this message]
2013-04-30 22:10 ` [PATCH 13/13] Bluetooth: Fix multiple LE socket handling Gustavo Padovan
2013-04-29 17:07 ` [PATCH 00/13] Bluetooth: L2CAP cleanups and fixes 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=1367253345-12482-14-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox