Linux bluetooth development
 help / color / mirror / Atom feed
From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 09/10] Bluetooth: Fix updating Identity Address in L2CAP channels
Date: Tue, 18 Feb 2014 17:14:38 +0200	[thread overview]
Message-ID: <1392736479-8808-10-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1392736479-8808-1-git-send-email-johan.hedberg@gmail.com>

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

When we receive a remote identity address during SMP key distribution we
should ensure that any associated L2CAP channel instances get their
address information correspondingly updated (so that e.g. doing
getpeername on associated sockets returns the correct address).

This patch adds a new L2CAP core function l2cap_conn_update_id_addr()
which is used to iterate through all L2CAP channels associated with a
connection and update their address information.

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

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 13bec91785f4..4abdcb220e3a 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -881,6 +881,7 @@ int l2cap_ertm_init(struct l2cap_chan *chan);
 void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
 void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
 void l2cap_chan_del(struct l2cap_chan *chan, int err);
+void l2cap_conn_update_id_addr(struct hci_conn *hcon);
 void l2cap_send_conn_req(struct l2cap_chan *chan);
 void l2cap_move_start(struct l2cap_chan *chan);
 void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6e6b3a9c8e6d..d25fefcc0bb5 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -609,6 +609,23 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 	return;
 }
 
+void l2cap_conn_update_id_addr(struct hci_conn *hcon)
+{
+	struct l2cap_conn *conn = hcon->l2cap_data;
+	struct l2cap_chan *chan;
+
+	mutex_lock(&conn->chan_lock);
+
+	list_for_each_entry(chan, &conn->chan_l, list) {
+		l2cap_chan_lock(chan);
+		bacpy(&chan->dst, &hcon->dst);
+		chan->dst_type = hcon->dst_type;
+		l2cap_chan_unlock(chan);
+	}
+
+	mutex_unlock(&conn->chan_lock);
+}
+
 static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)
 {
 	struct l2cap_conn *conn = chan->conn;
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 4d14ccc7b330..faf04bd4263a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -976,6 +976,8 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,
 	bacpy(&hcon->dst, &smp->id_addr);
 	hcon->dst_type = smp->id_addr_type;
 
+	l2cap_conn_update_id_addr(hcon);
+
 	smp_distribute_keys(conn, 1);
 
 	return 0;
-- 
1.8.5.3


  parent reply	other threads:[~2014-02-18 15:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 15:14 [PATCH 00/10] Bluetooth: More patches for privacy johan.hedberg
2014-02-18 15:14 ` [PATCH 01/10] Bluetooth: Remove SMP data specific crypto context johan.hedberg
2014-02-18 16:04   ` Marcel Holtmann
2014-02-18 16:24     ` Johan Hedberg
2014-02-18 16:29       ` Johan Hedberg
2014-02-18 17:34         ` Marcel Holtmann
2014-02-18 15:14 ` [PATCH 02/10] Bluetooth: Fix missing address type check for removing LTKs johan.hedberg
2014-02-18 15:14 ` [PATCH 03/10] Bluetooth: Remove return values from functions that don't need them johan.hedberg
2014-02-18 15:14 ` [PATCH 04/10] Bluetooth: Fix hci_remove_ltk failure when no match is found johan.hedberg
2014-02-18 15:14 ` [PATCH 05/10] Bluetooth: Fix completing SMP as peripheral when no keys are expected johan.hedberg
2014-02-18 15:14 ` [PATCH 06/10] Bluetooth: Fix removing any IRKs when unpairing devices johan.hedberg
2014-02-18 15:14 ` [PATCH 07/10] Bluetooth: Add convenience function for fetching IRKs johan.hedberg
2014-02-18 15:14 ` [PATCH 08/10] Bluetooth: Track the LE Identity Address in struct hci_conn johan.hedberg
2014-02-18 17:01   ` Marcel Holtmann
2014-02-18 15:14 ` johan.hedberg [this message]
2014-02-18 18:25   ` [PATCH 09/10] Bluetooth: Fix updating Identity Address in L2CAP channels Marcel Holtmann
2014-02-18 15:14 ` [PATCH 10/10] Bluetooth: Wait for SMP key distribution completion when pairing johan.hedberg
2014-02-18 15:44   ` [PATCH v2 " johan.hedberg
2014-02-18 18:28     ` Marcel Holtmann
2014-02-18 19:48       ` Johan Hedberg
2014-02-18 16:59 ` [PATCH 00/10] Bluetooth: More patches for privacy 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=1392736479-8808-10-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