* [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED)
@ 2012-05-24 22:59 Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This is already performed inside l2cap_chan_ready(), so we don't need it
here again.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c9e6ae4..b9c39f6 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3645,8 +3645,6 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) {
set_default_fcs(chan);
- l2cap_state_change(chan, BT_CONNECTED);
-
if (chan->mode == L2CAP_MODE_ERTM ||
chan->mode == L2CAP_MODE_STREAMING)
err = l2cap_ertm_init(chan);
@@ -3777,7 +3775,6 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
if (test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) {
set_default_fcs(chan);
- l2cap_state_change(chan, BT_CONNECTED);
if (chan->mode == L2CAP_MODE_ERTM ||
chan->mode == L2CAP_MODE_STREAMING)
err = l2cap_ertm_init(chan);
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 22:59 ` [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
` (6 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This remove a bit more of socket code from l2cap core, this calls set the
SOCK_ZAPPED and do some clean up depending on the socket state.
Reported-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 55 ++++++-----------------------------
net/bluetooth/l2cap_sock.c | 63 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 46 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 0142257..be3ce5a 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -526,6 +526,7 @@ struct l2cap_ops {
struct l2cap_chan *(*new_connection) (void *data);
int (*recv) (void *data, struct sk_buff *skb);
void (*close) (void *data);
+ void (*teardown) (void *data, int err);
void (*state_change) (void *data, int state);
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b9c39f6..9f5fc4f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -493,9 +493,7 @@ static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
static void l2cap_chan_del(struct l2cap_chan *chan, int err)
{
- struct sock *sk = chan->sk;
struct l2cap_conn *conn = chan->conn;
- struct sock *parent = bt_sk(sk)->parent;
__clear_chan_timer(chan);
@@ -511,21 +509,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
hci_conn_put(conn->hcon);
}
- lock_sock(sk);
-
- __l2cap_state_change(chan, BT_CLOSED);
- sock_set_flag(sk, SOCK_ZAPPED);
-
- if (err)
- __l2cap_chan_set_err(chan, err);
-
- if (parent) {
- bt_accept_unlink(sk);
- parent->sk_data_ready(parent, 0);
- } else
- sk->sk_state_change(sk);
-
- release_sock(sk);
+ if (chan->ops->teardown)
+ chan->ops->teardown(chan->data, err);
if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
return;
@@ -554,25 +539,6 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
return;
}
-static void l2cap_chan_cleanup_listen(struct sock *parent)
-{
- struct sock *sk;
-
- BT_DBG("parent %p", parent);
-
- /* Close not yet accepted channels */
- while ((sk = bt_accept_dequeue(parent, NULL))) {
- struct l2cap_chan *chan = l2cap_pi(sk)->chan;
-
- l2cap_chan_lock(chan);
- __clear_chan_timer(chan);
- l2cap_chan_close(chan, ECONNRESET);
- l2cap_chan_unlock(chan);
-
- chan->ops->close(chan->data);
- }
-}
-
void l2cap_chan_close(struct l2cap_chan *chan, int reason)
{
struct l2cap_conn *conn = chan->conn;
@@ -583,12 +549,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
switch (chan->state) {
case BT_LISTEN:
- lock_sock(sk);
- l2cap_chan_cleanup_listen(sk);
-
- __l2cap_state_change(chan, BT_CLOSED);
- sock_set_flag(sk, SOCK_ZAPPED);
- release_sock(sk);
+ if (chan->ops->teardown)
+ chan->ops->teardown(chan->data, 0);
break;
case BT_CONNECTED:
@@ -630,9 +592,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
break;
default:
- lock_sock(sk);
- sock_set_flag(sk, SOCK_ZAPPED);
- release_sock(sk);
+ if (chan->ops->teardown)
+ chan->ops->teardown(chan->data, 0);
break;
}
}
@@ -3416,7 +3377,9 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
/* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(conn, scid)) {
- sock_set_flag(sk, SOCK_ZAPPED);
+ if (chan->ops->teardown)
+ chan->ops->teardown(chan->data, 0);
+
chan->ops->close(chan->data);
goto response;
}
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 4d36605..c5a1b57 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -872,6 +872,25 @@ static int l2cap_sock_release(struct socket *sock)
return err;
}
+static void l2cap_sock_cleanup_listen(struct sock *parent)
+{
+ struct sock *sk;
+
+ BT_DBG("parent %p", parent);
+
+ /* Close not yet accepted channels */
+ while ((sk = bt_accept_dequeue(parent, NULL))) {
+ struct l2cap_chan *chan = l2cap_pi(sk)->chan;
+
+ l2cap_chan_lock(chan);
+ __clear_chan_timer(chan);
+ l2cap_chan_close(chan, ECONNRESET);
+ l2cap_chan_unlock(chan);
+
+ l2cap_sock_kill(sk);
+ }
+}
+
static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
{
struct sock *sk, *parent = data;
@@ -931,6 +950,49 @@ static void l2cap_sock_close_cb(void *data)
l2cap_sock_kill(sk);
}
+static void l2cap_sock_teardown_cb(void *data, int err)
+{
+ struct sock *sk = data;
+ struct sock *parent;
+ struct l2cap_chan *chan;
+
+ lock_sock(sk);
+
+ parent = bt_sk(sk)->parent;
+ chan = l2cap_pi(sk)->chan;
+
+ sock_set_flag(sk, SOCK_ZAPPED);
+
+ switch (chan->state) {
+ case BT_OPEN:
+ case BT_BOUND:
+ case BT_CLOSED:
+ break;
+ case BT_LISTEN:
+ l2cap_sock_cleanup_listen(sk);
+ sk->sk_state = BT_CLOSED;
+ chan->state = BT_CLOSED;
+
+ break;
+ default:
+ sk->sk_state = BT_CLOSED;
+ chan->state = BT_CLOSED;
+
+ sk->sk_err = err;
+
+ if (parent) {
+ bt_accept_unlink(sk);
+ parent->sk_data_ready(parent, 0);
+ } else {
+ sk->sk_state_change(sk);
+ }
+
+ break;
+ }
+
+ release_sock(sk);
+}
+
static void l2cap_sock_state_change_cb(void *data, int state)
{
struct sock *sk = data;
@@ -959,6 +1021,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.new_connection = l2cap_sock_new_connection_cb,
.recv = l2cap_sock_recv_cb,
.close = l2cap_sock_close_cb,
+ .teardown = l2cap_sock_teardown_cb,
.state_change = l2cap_sock_state_change_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
};
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready()
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 22:59 ` [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This move socket specific code to l2cap_sock.c.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 18 +++---------------
net/bluetooth/l2cap_sock.c | 21 +++++++++++++++++++++
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index be3ce5a..fac6996 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -530,6 +530,7 @@ struct l2cap_ops {
void (*state_change) (void *data, int state);
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb);
+ void (*ready) (void *data);
};
struct l2cap_conn {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9f5fc4f..b808955 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -931,26 +931,14 @@ static void l2cap_send_conn_req(struct l2cap_chan *chan)
static void l2cap_chan_ready(struct l2cap_chan *chan)
{
- struct sock *sk = chan->sk;
- struct sock *parent;
-
- lock_sock(sk);
-
- parent = bt_sk(sk)->parent;
-
- BT_DBG("sk %p, parent %p", sk, parent);
-
/* This clears all conf flags, including CONF_NOT_COMPLETE */
chan->conf_state = 0;
__clear_chan_timer(chan);
- __l2cap_state_change(chan, BT_CONNECTED);
- sk->sk_state_change(sk);
-
- if (parent)
- parent->sk_data_ready(parent, 0);
+ chan->state = BT_CONNECTED;
- release_sock(sk);
+ if (chan->ops->ready)
+ chan->ops->ready(chan->data);
}
static void l2cap_do_start(struct l2cap_chan *chan)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index c5a1b57..6730905 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1016,6 +1016,26 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
return skb;
}
+static void l2cap_sock_ready_cb(void *data)
+{
+ struct sock *sk = data;
+ struct sock *parent;
+
+ lock_sock(sk);
+
+ parent = bt_sk(sk)->parent;
+
+ BT_DBG("sk %p, parent %p", sk, parent);
+
+ sk->sk_state = BT_CONNECTED;
+ sk->sk_state_change(sk);
+
+ if (parent)
+ parent->sk_data_ready(parent, 0);
+
+ release_sock(sk);
+}
+
static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
@@ -1024,6 +1044,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.teardown = l2cap_sock_teardown_cb,
.state_change = l2cap_sock_state_change_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
+ .ready = l2cap_sock_ready_cb,
};
static void l2cap_sock_destruct(struct sock *sk)
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24 22:59 ` [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 22:59 ` [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This replace code in l2cap_le_conn_ready() by a similar code in
l2cap_chan_ready().
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b808955..aa77a93 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1177,10 +1177,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
l2cap_chan_add(conn, chan);
- __set_chan_timer(chan, sk->sk_sndtimeo);
-
- __l2cap_state_change(chan, BT_CONNECTED);
- parent->sk_data_ready(parent, 0);
+ l2cap_chan_ready(chan);
clean:
release_sock(parent);
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
` (2 preceding siblings ...)
2012-05-24 22:59 ` [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
These vars are kept in sync so we can use chan->state here.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index aa77a93..377dc7e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1444,7 +1444,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
lock_sock(sk);
- switch (sk->sk_state) {
+ switch (chan->state) {
case BT_CONNECT:
case BT_CONNECT2:
case BT_CONFIG:
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
` (3 preceding siblings ...)
2012-05-24 22:59 ` [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-25 7:17 ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
` (2 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Remove socket specific code from l2cap_core.c
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 12 ------------
net/bluetooth/l2cap_sock.c | 6 ++++++
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 377dc7e..d7febe1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1156,12 +1156,6 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
lock_sock(parent);
- /* Check for backlog size */
- if (sk_acceptq_is_full(parent)) {
- BT_DBG("backlog full %d", parent->sk_ack_backlog);
- goto clean;
- }
-
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
goto clean;
@@ -3348,12 +3342,6 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
result = L2CAP_CR_NO_MEM;
- /* Check for backlog size */
- if (sk_acceptq_is_full(parent)) {
- BT_DBG("backlog full %d", parent->sk_ack_backlog);
- goto response;
- }
-
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
goto response;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 6730905..3101f25 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -895,6 +895,12 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
{
struct sock *sk, *parent = data;
+ /* Check for backlog size */
+ if (sk_acceptq_is_full(parent)) {
+ BT_DBG("backlog full %d", parent->sk_ack_backlog);
+ return NULL;
+ }
+
sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
GFP_ATOMIC);
if (!sk)
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
` (4 preceding siblings ...)
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
7 siblings, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Remove another socket usage from l2cap_core.c
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 12 ++++++------
net/bluetooth/l2cap_sock.c | 8 ++++++--
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index fac6996..46b5cff 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -595,6 +595,7 @@ enum {
CONF_LOC_CONF_PEND,
CONF_REM_CONF_PEND,
CONF_NOT_COMPLETE,
+ CONF_DEFER_SETUP,
};
#define L2CAP_CONF_MAX_CONF_REQ 2
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d7febe1..20e4a9b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -569,7 +569,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
struct l2cap_conn_rsp rsp;
__u16 result;
- if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))
+ if (test_bit(CONF_DEFER_SETUP, &chan->conf_state))
result = L2CAP_CR_SEC_BLOCK;
else
result = L2CAP_CR_BAD_PSM;
@@ -1056,8 +1056,8 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
if (l2cap_chan_check_security(chan)) {
lock_sock(sk);
- if (test_bit(BT_SK_DEFER_SETUP,
- &bt_sk(sk)->flags)) {
+ if (test_bit(CONF_DEFER_SETUP,
+ &chan->conf_state)) {
struct sock *parent = bt_sk(sk)->parent;
rsp.result = cpu_to_le16(L2CAP_CR_PEND);
rsp.status = cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
@@ -3376,7 +3376,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) {
if (l2cap_chan_check_security(chan)) {
- if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
+ if (test_bit(CONF_DEFER_SETUP, &chan->conf_state)) {
__l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHOR_PEND;
@@ -5406,8 +5406,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
lock_sock(sk);
if (!status) {
- if (test_bit(BT_SK_DEFER_SETUP,
- &bt_sk(sk)->flags)) {
+ if (test_bit(CONF_DEFER_SETUP,
+ &chan->conf_state)) {
struct sock *parent = bt_sk(sk)->parent;
res = L2CAP_CR_PEND;
stat = L2CAP_CS_AUTHOR_PEND;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3101f25..251817d 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -623,10 +623,14 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
break;
}
- if (opt)
+ if (opt) {
set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
- else
+ set_bit(CONF_DEFER_SETUP, &chan->conf_state);
+ } else {
clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
+ clear_bit(CONF_DEFER_SETUP, &chan->conf_state);
+ }
+
break;
case BT_FLUSHABLE:
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/12] Bluetooth: Add chan->ops->defer()
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
` (5 preceding siblings ...)
2012-05-24 22:59 ` [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-25 7:29 ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
7 siblings, 1 reply; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
When DEFER_SETUP is set defer() will trigger an authorization request
to the userspace.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 14 ++++++--------
net/bluetooth/l2cap_sock.c | 12 ++++++++++++
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 46b5cff..b03861f 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -531,6 +531,7 @@ struct l2cap_ops {
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long len, int nb);
void (*ready) (void *data);
+ void (*defer) (void *data);
};
struct l2cap_conn {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 20e4a9b..7719508 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1058,12 +1058,10 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
lock_sock(sk);
if (test_bit(CONF_DEFER_SETUP,
&chan->conf_state)) {
- struct sock *parent = bt_sk(sk)->parent;
rsp.result = cpu_to_le16(L2CAP_CR_PEND);
rsp.status = cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
- if (parent)
- parent->sk_data_ready(parent, 0);
-
+ if(chan->ops->defer)
+ chan->ops->defer(chan->data);
} else {
__l2cap_state_change(chan, BT_CONFIG);
rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
@@ -3380,7 +3378,8 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
__l2cap_state_change(chan, BT_CONNECT2);
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHOR_PEND;
- parent->sk_data_ready(parent, 0);
+ if(chan->ops->defer)
+ chan->ops->defer(chan->data);
} else {
__l2cap_state_change(chan, BT_CONFIG);
result = L2CAP_CR_SUCCESS;
@@ -5408,11 +5407,10 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
if (!status) {
if (test_bit(CONF_DEFER_SETUP,
&chan->conf_state)) {
- struct sock *parent = bt_sk(sk)->parent;
res = L2CAP_CR_PEND;
stat = L2CAP_CS_AUTHOR_PEND;
- if (parent)
- parent->sk_data_ready(parent, 0);
+ if(chan->ops->defer)
+ chan->ops->defer(chan->data);
} else {
__l2cap_state_change(chan, BT_CONFIG);
res = L2CAP_CR_SUCCESS;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 251817d..44a5c72 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1046,6 +1046,17 @@ static void l2cap_sock_ready_cb(void *data)
release_sock(sk);
}
+static void l2cap_sock_defer_cb(void *data)
+{
+ struct sock *sk = data;
+ struct sock *parent;
+
+ parent = bt_sk(sk)->parent;
+
+ if (parent)
+ parent->sk_data_ready(parent, 0);
+}
+
static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
@@ -1055,6 +1066,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.state_change = l2cap_sock_state_change_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
.ready = l2cap_sock_ready_cb,
+ .defer = l2cap_sock_defer_cb,
};
static void l2cap_sock_destruct(struct sock *sk)
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/12] Bluetooth: check for already existent channel before create new one
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
` (6 preceding siblings ...)
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
@ 2012-05-24 22:59 ` Gustavo Padovan
2012-05-24 23:05 ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-25 7:32 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko
7 siblings, 2 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 22:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Move this check to before the channel time creation simplifies the code
and avoid memory allocation if the channel already exist.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 7719508..0df7f49 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3340,21 +3340,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
result = L2CAP_CR_NO_MEM;
+ /* Check if we already have channel with that dcid */
+ if (__l2cap_get_chan_by_dcid(conn, scid))
+ goto response;
+
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
goto response;
sk = chan->sk;
- /* Check if we already have channel with that dcid */
- if (__l2cap_get_chan_by_dcid(conn, scid)) {
- if (chan->ops->teardown)
- chan->ops->teardown(chan->data, 0);
-
- chan->ops->close(chan->data);
- goto response;
- }
-
hci_conn_hold(conn->hcon);
bacpy(&bt_sk(sk)->src, conn->src);
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
@ 2012-05-24 23:05 ` Gustavo Padovan
2012-05-24 23:05 ` [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24 23:05 ` [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
2012-05-25 7:32 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko
1 sibling, 2 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
bt_accept_enqueue() can be easily placed at the end of
l2cap_sock_new_connection_cb().
There is no problem in moving to bt_accept_enqueue() to an earlier point
in the code, bt_accept_enqueue() only the sk to the it parents queue
basically.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 4 ----
net/bluetooth/l2cap_sock.c | 2 ++
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0df7f49..7946d5c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1165,8 +1165,6 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
bacpy(&bt_sk(sk)->src, conn->src);
bacpy(&bt_sk(sk)->dst, conn->dst);
- bt_accept_enqueue(parent, sk);
-
l2cap_chan_add(conn, chan);
l2cap_chan_ready(chan);
@@ -3357,8 +3355,6 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
chan->psm = psm;
chan->dcid = scid;
- bt_accept_enqueue(parent, sk);
-
__l2cap_chan_add(conn, chan);
dcid = chan->scid;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 44a5c72..1b6a675 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -914,6 +914,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
l2cap_sock_init(sk, parent);
+ bt_accept_enqueue(parent, sk);
+
return l2cap_pi(sk)->chan;
}
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c
2012-05-24 23:05 ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
@ 2012-05-24 23:05 ` Gustavo Padovan
2012-05-24 23:05 ` [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
1 sibling, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
We can lock the parent lock only inside the new_connection() call, then we
just use the l2cap_chan_lock() in core code.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 16 ++++++----------
net/bluetooth/l2cap_sock.c | 9 ++++++++-
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 7946d5c..c38447b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1139,7 +1139,7 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
static void l2cap_le_conn_ready(struct l2cap_conn *conn)
{
- struct sock *parent, *sk;
+ struct sock *sk;
struct l2cap_chan *chan, *pchan;
BT_DBG("");
@@ -1150,9 +1150,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
if (!pchan)
return;
- parent = pchan->sk;
-
- lock_sock(parent);
+ l2cap_chan_lock(pchan);
chan = pchan->ops->new_connection(pchan->data);
if (!chan)
@@ -1170,7 +1168,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
l2cap_chan_ready(chan);
clean:
- release_sock(parent);
+ l2cap_chan_unlock(pchan);
}
static void l2cap_conn_ready(struct l2cap_conn *conn)
@@ -3308,7 +3306,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
struct l2cap_conn_rsp rsp;
struct l2cap_chan *chan = NULL, *pchan;
- struct sock *parent, *sk = NULL;
+ struct sock *sk = NULL;
int result, status = L2CAP_CS_NO_INFO;
u16 dcid = 0, scid = __le16_to_cpu(req->scid);
@@ -3323,10 +3321,8 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
goto sendresp;
}
- parent = pchan->sk;
-
mutex_lock(&conn->chan_lock);
- lock_sock(parent);
+ l2cap_chan_lock(pchan);
/* Check if the ACL is secure enough (if not SDP) */
if (psm != cpu_to_le16(0x0001) &&
@@ -3388,7 +3384,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
}
response:
- release_sock(parent);
+ l2cap_chan_unlock(pchan);
mutex_unlock(&conn->chan_lock);
sendresp:
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1b6a675..22f1874 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -899,16 +899,21 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
{
struct sock *sk, *parent = data;
+ lock_sock(parent);
+
/* Check for backlog size */
if (sk_acceptq_is_full(parent)) {
BT_DBG("backlog full %d", parent->sk_ack_backlog);
+ release_sock(parent);
return NULL;
}
sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
GFP_ATOMIC);
- if (!sk)
+ if (!sk) {
+ release_sock(parent);
return NULL;
+ }
bt_sock_reclassify_lock(sk, BTPROTO_L2CAP);
@@ -916,6 +921,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
bt_accept_enqueue(parent, sk);
+ release_sock(parent);
+
return l2cap_pi(sk)->chan;
}
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb()
2012-05-24 23:05 ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24 23:05 ` [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
@ 2012-05-24 23:05 ` Gustavo Padovan
1 sibling, 0 replies; 15+ messages in thread
From: Gustavo Padovan @ 2012-05-24 23:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This keep l2cap chan ops functions parameters in sync.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
include/net/bluetooth/l2cap.h | 4 ++--
net/bluetooth/l2cap_core.c | 8 ++++----
net/bluetooth/l2cap_sock.c | 8 +++++---
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index b03861f..8a1c741 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -528,8 +528,8 @@ struct l2cap_ops {
void (*close) (void *data);
void (*teardown) (void *data, int err);
void (*state_change) (void *data, int state);
- struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
- unsigned long len, int nb);
+ struct sk_buff *(*alloc_skb) (void *data, unsigned long len,
+ int nb);
void (*ready) (void *data);
void (*defer) (void *data);
};
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c38447b..71ca1ef 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1893,7 +1893,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
count = min_t(unsigned int, conn->mtu, len);
- tmp = chan->ops->alloc_skb(chan, count,
+ tmp = chan->ops->alloc_skb(chan->data, count,
msg->msg_flags & MSG_DONTWAIT);
if (IS_ERR(tmp))
return PTR_ERR(tmp);
@@ -1930,7 +1930,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan,
count = min_t(unsigned int, (conn->mtu - hlen), len);
- skb = chan->ops->alloc_skb(chan, count + hlen,
+ skb = chan->ops->alloc_skb(chan->data, count + hlen,
msg->msg_flags & MSG_DONTWAIT);
if (IS_ERR(skb))
return skb;
@@ -1964,7 +1964,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan,
count = min_t(unsigned int, (conn->mtu - L2CAP_HDR_SIZE), len);
- skb = chan->ops->alloc_skb(chan, count + L2CAP_HDR_SIZE,
+ skb = chan->ops->alloc_skb(chan->data, count + L2CAP_HDR_SIZE,
msg->msg_flags & MSG_DONTWAIT);
if (IS_ERR(skb))
return skb;
@@ -2011,7 +2011,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan,
count = min_t(unsigned int, (conn->mtu - hlen), len);
- skb = chan->ops->alloc_skb(chan, count + hlen,
+ skb = chan->ops->alloc_skb(chan->data, count + hlen,
msg->msg_flags & MSG_DONTWAIT);
if (IS_ERR(skb))
return skb;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 22f1874..fa98be7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1019,14 +1019,16 @@ static void l2cap_sock_state_change_cb(void *data, int state)
sk->sk_state = state;
}
-static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
- unsigned long len, int nb)
+static struct sk_buff *l2cap_sock_alloc_skb_cb(void *data, unsigned long len,
+ int nb)
{
+ struct sock *sk = data;
+ struct l2cap_chan *chan = l2cap_pi(sk)->chan;
struct sk_buff *skb;
int err;
l2cap_chan_unlock(chan);
- skb = bt_skb_send_alloc(chan->sk, len, nb, &err);
+ skb = bt_skb_send_alloc(sk, len, nb, &err);
l2cap_chan_lock(chan);
if (!skb)
--
1.7.10.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
@ 2012-05-25 7:17 ` Andrei Emeltchenko
0 siblings, 0 replies; 15+ messages in thread
From: Andrei Emeltchenko @ 2012-05-25 7:17 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
Hi Gustavo,
On Thu, May 24, 2012 at 07:59:46PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Remove socket specific code from l2cap_core.c
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 08/12] Bluetooth: Add chan->ops->defer()
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
@ 2012-05-25 7:29 ` Andrei Emeltchenko
0 siblings, 0 replies; 15+ messages in thread
From: Andrei Emeltchenko @ 2012-05-25 7:29 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
Hi Gustavo,
On Thu, May 24, 2012 at 07:59:48PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> When DEFER_SETUP is set defer() will trigger an authorization request
> to the userspace.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 14 ++++++--------
> net/bluetooth/l2cap_sock.c | 12 ++++++++++++
> 3 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 46b5cff..b03861f 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -531,6 +531,7 @@ struct l2cap_ops {
> struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
> unsigned long len, int nb);
> void (*ready) (void *data);
> + void (*defer) (void *data);
> };
>
> struct l2cap_conn {
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 20e4a9b..7719508 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1058,12 +1058,10 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
> lock_sock(sk);
> if (test_bit(CONF_DEFER_SETUP,
> &chan->conf_state)) {
> - struct sock *parent = bt_sk(sk)->parent;
> rsp.result = cpu_to_le16(L2CAP_CR_PEND);
> rsp.status = cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
Looks like this is not against the latest tree ;)
Otherwise looks good.
Best regards
Andrei Emeltchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 09/12] Bluetooth: check for already existent channel before create new one
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24 23:05 ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
@ 2012-05-25 7:32 ` Andrei Emeltchenko
1 sibling, 0 replies; 15+ messages in thread
From: Andrei Emeltchenko @ 2012-05-25 7:32 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
Hi Gustavo,
On Thu, May 24, 2012 at 07:59:49PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Move this check to before the channel time creation simplifies the code
> and avoid memory allocation if the channel already exist.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 7719508..0df7f49 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3340,21 +3340,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
>
> result = L2CAP_CR_NO_MEM;
>
> + /* Check if we already have channel with that dcid */
> + if (__l2cap_get_chan_by_dcid(conn, scid))
> + goto response;
> +
> chan = pchan->ops->new_connection(pchan->data);
> if (!chan)
> goto response;
>
> sk = chan->sk;
>
> - /* Check if we already have channel with that dcid */
> - if (__l2cap_get_chan_by_dcid(conn, scid)) {
> - if (chan->ops->teardown)
> - chan->ops->teardown(chan->data, 0);
> -
> - chan->ops->close(chan->data);
> - goto response;
> - }
> -
> hci_conn_hold(conn->hcon);
>
> bacpy(&bt_sk(sk)->src, conn->src);
> --
> 1.7.10.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2012-05-25 7:32 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24 22:59 ` [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
2012-05-24 22:59 ` [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-24 22:59 ` [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-25 7:17 ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
2012-05-25 7:29 ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24 23:05 ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24 23:05 ` [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24 23:05 ` [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
2012-05-25 7:32 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox