* [RFC] Bluetooth: Adds unlink to chan ops
@ 2012-05-23 8:05 Andrei Emeltchenko
2012-05-23 11:03 ` Ulisses Furquim
2012-05-23 20:31 ` Gustavo Padovan
0 siblings, 2 replies; 6+ messages in thread
From: Andrei Emeltchenko @ 2012-05-23 8:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: mathewm
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This helps to separate socket and socketless code. Now socket related
operations moved to l2cap_sock in unlink callback for channels with sk.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reported-by: Mat Martineau <mathewm@codeaurora.org>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 20 ++------------------
net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 69ef077..7ed13e7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -532,6 +532,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 (*unlink) (struct l2cap_chan *chan, int err);
};
struct l2cap_conn {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c64da38..d2b16b5 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -520,9 +520,7 @@ 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;
__clear_chan_timer(chan);
@@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
goto clean;
- lock_sock(sk);
-
- __l2cap_state_change(chan, BT_CLOSED);
- sock_set_flag(sk, SOCK_ZAPPED);
-
- if (err)
- __l2cap_chan_set_err(chan, err);
-
- parent = bt_sk(sk)->parent;
- if (parent) {
- bt_accept_unlink(sk);
- parent->sk_data_ready(parent, 0);
- } else
- sk->sk_state_change(sk);
-
- release_sock(sk);
+ if (chan->ops->unlink)
+ chan->ops->unlink(chan, err);
if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
return;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3bb1611..d6f481b 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
return skb;
}
+static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
+{
+ struct sock *sk = chan->sk;
+ struct sock *parent = bt_sk(sk)->parent;
+
+ lock_sock(sk);
+
+ chan->state = BT_CLOSED;
+ sk->sk_state = BT_CLOSED;
+ sock_set_flag(sk, SOCK_ZAPPED);
+
+ if (err)
+ sk->sk_err = err;
+
+ parent = bt_sk(sk)->parent;
+ if (parent) {
+ bt_accept_unlink(sk);
+ parent->sk_data_ready(parent, 0);
+ } else
+ sk->sk_state_change(sk);
+
+ release_sock(sk);
+}
+
static struct l2cap_ops l2cap_chan_ops = {
.name = "L2CAP Socket Interface",
.new_connection = l2cap_sock_new_connection_cb,
@@ -962,6 +986,7 @@ static struct l2cap_ops l2cap_chan_ops = {
.close = l2cap_sock_close_cb,
.state_change = l2cap_sock_state_change_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb,
+ .unlink = l2cap_sock_unlink_cb,
};
static void l2cap_sock_destruct(struct sock *sk)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC] Bluetooth: Adds unlink to chan ops
2012-05-23 8:05 [RFC] Bluetooth: Adds unlink to chan ops Andrei Emeltchenko
@ 2012-05-23 11:03 ` Ulisses Furquim
2012-05-23 20:31 ` Gustavo Padovan
1 sibling, 0 replies; 6+ messages in thread
From: Ulisses Furquim @ 2012-05-23 11:03 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth, mathewm
Hi Andrei,
On Wed, May 23, 2012 at 5:05 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> This helps to separate socket and socketless code. Now socket related
> operations moved to l2cap_sock in unlink callback for channels with sk.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 20 ++------------------
> net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
> 3 files changed, 28 insertions(+), 18 deletions(-)
Looks good also, keep up the work. :-)
Best regards,
--
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Bluetooth: Adds unlink to chan ops
2012-05-23 8:05 [RFC] Bluetooth: Adds unlink to chan ops Andrei Emeltchenko
2012-05-23 11:03 ` Ulisses Furquim
@ 2012-05-23 20:31 ` Gustavo Padovan
2012-05-23 22:03 ` Ulisses Furquim
1 sibling, 1 reply; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-23 20:31 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth, mathewm
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-23 11:05:49 +0300]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> This helps to separate socket and socketless code. Now socket related
> operations moved to l2cap_sock in unlink callback for channels with sk.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> ---
> include/net/bluetooth/l2cap.h | 1 +
> net/bluetooth/l2cap_core.c | 20 ++------------------
> net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
> 3 files changed, 28 insertions(+), 18 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 69ef077..7ed13e7 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -532,6 +532,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 (*unlink) (struct l2cap_chan *chan, int err);
> };
>
> struct l2cap_conn {
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index c64da38..d2b16b5 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -520,9 +520,7 @@ 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;
>
> __clear_chan_timer(chan);
>
> @@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
> if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
> goto clean;
>
> - lock_sock(sk);
> -
> - __l2cap_state_change(chan, BT_CLOSED);
> - sock_set_flag(sk, SOCK_ZAPPED);
> -
> - if (err)
> - __l2cap_chan_set_err(chan, err);
> -
> - parent = bt_sk(sk)->parent;
> - if (parent) {
> - bt_accept_unlink(sk);
> - parent->sk_data_ready(parent, 0);
> - } else
> - sk->sk_state_change(sk);
> -
> - release_sock(sk);
> + if (chan->ops->unlink)
> + chan->ops->unlink(chan, err);
>
> if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
> return;
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 3bb1611..d6f481b 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
> return skb;
> }
>
> +static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
> +{
> + struct sock *sk = chan->sk;
> + struct sock *parent = bt_sk(sk)->parent;
> +
> + lock_sock(sk);
> +
> + chan->state = BT_CLOSED;
> + sk->sk_state = BT_CLOSED;
> + sock_set_flag(sk, SOCK_ZAPPED);
I think we can improve this code and call it everytime we need to set
SOCK_ZAPPED. We just need a bit more of logic here.
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Bluetooth: Adds unlink to chan ops
2012-05-23 20:31 ` Gustavo Padovan
@ 2012-05-23 22:03 ` Ulisses Furquim
2012-05-24 8:18 ` Andrei Emeltchenko
0 siblings, 1 reply; 6+ messages in thread
From: Ulisses Furquim @ 2012-05-23 22:03 UTC (permalink / raw)
To: Gustavo Padovan, Andrei Emeltchenko, linux-bluetooth, mathewm
Hi Gustavo,
On Wed, May 23, 2012 at 5:31 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> Hi Andrei,
>
> * Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-23 11:05:49 +0300]:
>
>> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>>
>> This helps to separate socket and socketless code. Now socket related
>> operations moved to l2cap_sock in unlink callback for channels with sk.
>>
>> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>> Reported-by: Mat Martineau <mathewm@codeaurora.org>
>> ---
>> include/net/bluetooth/l2cap.h | 1 +
>> net/bluetooth/l2cap_core.c | 20 ++------------------
>> net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
>> 3 files changed, 28 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
>> index 69ef077..7ed13e7 100644
>> --- a/include/net/bluetooth/l2cap.h
>> +++ b/include/net/bluetooth/l2cap.h
>> @@ -532,6 +532,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 (*unlink) (struct l2cap_chan *chan, int err);
>> };
>>
>> struct l2cap_conn {
>> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
>> index c64da38..d2b16b5 100644
>> --- a/net/bluetooth/l2cap_core.c
>> +++ b/net/bluetooth/l2cap_core.c
>> @@ -520,9 +520,7 @@ 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;
>>
>> __clear_chan_timer(chan);
>>
>> @@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
>> if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
>> goto clean;
>>
>> - lock_sock(sk);
>> -
>> - __l2cap_state_change(chan, BT_CLOSED);
>> - sock_set_flag(sk, SOCK_ZAPPED);
>> -
>> - if (err)
>> - __l2cap_chan_set_err(chan, err);
>> -
>> - parent = bt_sk(sk)->parent;
>> - if (parent) {
>> - bt_accept_unlink(sk);
>> - parent->sk_data_ready(parent, 0);
>> - } else
>> - sk->sk_state_change(sk);
>> -
>> - release_sock(sk);
>> + if (chan->ops->unlink)
>> + chan->ops->unlink(chan, err);
>>
>> if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
>> return;
>> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
>> index 3bb1611..d6f481b 100644
>> --- a/net/bluetooth/l2cap_sock.c
>> +++ b/net/bluetooth/l2cap_sock.c
>> @@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
>> return skb;
>> }
>>
>> +static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
>> +{
>> + struct sock *sk = chan->sk;
>> + struct sock *parent = bt_sk(sk)->parent;
>> +
>> + lock_sock(sk);
>> +
>> + chan->state = BT_CLOSED;
>> + sk->sk_state = BT_CLOSED;
>> + sock_set_flag(sk, SOCK_ZAPPED);
>
> I think we can improve this code and call it everytime we need to set
> SOCK_ZAPPED. We just need a bit more of logic here.
We might, if it's not a big of a change. Otherwise I think this kind
of change needs to be incremental.
Regards,
--
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Bluetooth: Adds unlink to chan ops
2012-05-23 22:03 ` Ulisses Furquim
@ 2012-05-24 8:18 ` Andrei Emeltchenko
2012-05-24 8:33 ` Gustavo Padovan
0 siblings, 1 reply; 6+ messages in thread
From: Andrei Emeltchenko @ 2012-05-24 8:18 UTC (permalink / raw)
To: Ulisses Furquim; +Cc: Gustavo Padovan, linux-bluetooth, mathewm
Hi Gustavo and Ulisses,
On Wed, May 23, 2012 at 07:03:21PM -0300, Ulisses Furquim wrote:
> Hi Gustavo,
>
> On Wed, May 23, 2012 at 5:31 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> > Hi Andrei,
> >
> > * Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-23 11:05:49 +0300]:
> >
> >> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >>
> >> This helps to separate socket and socketless code. Now socket related
> >> operations moved to l2cap_sock in unlink callback for channels with sk.
> >>
> >> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> >> ---
> >> include/net/bluetooth/l2cap.h | 1 +
> >> net/bluetooth/l2cap_core.c | 20 ++------------------
> >> net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
> >> 3 files changed, 28 insertions(+), 18 deletions(-)
> >>
> >> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> >> index 69ef077..7ed13e7 100644
> >> --- a/include/net/bluetooth/l2cap.h
> >> +++ b/include/net/bluetooth/l2cap.h
> >> @@ -532,6 +532,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 (*unlink) (struct l2cap_chan *chan, int err);
> >> };
> >>
> >> struct l2cap_conn {
> >> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> >> index c64da38..d2b16b5 100644
> >> --- a/net/bluetooth/l2cap_core.c
> >> +++ b/net/bluetooth/l2cap_core.c
> >> @@ -520,9 +520,7 @@ 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;
> >>
> >> __clear_chan_timer(chan);
> >>
> >> @@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
> >> if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
> >> goto clean;
> >>
> >> - lock_sock(sk);
> >> -
> >> - __l2cap_state_change(chan, BT_CLOSED);
> >> - sock_set_flag(sk, SOCK_ZAPPED);
> >> -
> >> - if (err)
> >> - __l2cap_chan_set_err(chan, err);
> >> -
> >> - parent = bt_sk(sk)->parent;
> >> - if (parent) {
> >> - bt_accept_unlink(sk);
> >> - parent->sk_data_ready(parent, 0);
> >> - } else
> >> - sk->sk_state_change(sk);
> >> -
> >> - release_sock(sk);
> >> + if (chan->ops->unlink)
> >> + chan->ops->unlink(chan, err);
> >>
> >> if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
> >> return;
> >> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> >> index 3bb1611..d6f481b 100644
> >> --- a/net/bluetooth/l2cap_sock.c
> >> +++ b/net/bluetooth/l2cap_sock.c
> >> @@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
> >> return skb;
> >> }
> >>
> >> +static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
> >> +{
> >> + struct sock *sk = chan->sk;
> >> + struct sock *parent = bt_sk(sk)->parent;
> >> +
> >> + lock_sock(sk);
> >> +
> >> + chan->state = BT_CLOSED;
> >> + sk->sk_state = BT_CLOSED;
> >> + sock_set_flag(sk, SOCK_ZAPPED);
> >
> > I think we can improve this code and call it everytime we need to set
> > SOCK_ZAPPED. We just need a bit more of logic here.
>
> We might, if it's not a big of a change. Otherwise I think this kind
> of change needs to be incremental.
I agree with Ulisses that it shall be incremental since it is not
straightforward. I am thinking that sock_set_flag(sk, SOCK_ZAPPED) might
be put before switch in l2cap_chan_close and maybe further. Then we need
to think about how to make it working for socketless chans...
Best regards
Andrei Emeltchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Bluetooth: Adds unlink to chan ops
2012-05-24 8:18 ` Andrei Emeltchenko
@ 2012-05-24 8:33 ` Gustavo Padovan
0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-24 8:33 UTC (permalink / raw)
To: Andrei Emeltchenko, Ulisses Furquim, linux-bluetooth, mathewm
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-24 11:18:23 +0300]:
> Hi Gustavo and Ulisses,
>
> On Wed, May 23, 2012 at 07:03:21PM -0300, Ulisses Furquim wrote:
> > Hi Gustavo,
> >
> > On Wed, May 23, 2012 at 5:31 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> > > Hi Andrei,
> > >
> > > * Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-05-23 11:05:49 +0300]:
> > >
> > >> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > >>
> > >> This helps to separate socket and socketless code. Now socket related
> > >> operations moved to l2cap_sock in unlink callback for channels with sk.
> > >>
> > >> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > >> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> > >> ---
> > >> include/net/bluetooth/l2cap.h | 1 +
> > >> net/bluetooth/l2cap_core.c | 20 ++------------------
> > >> net/bluetooth/l2cap_sock.c | 25 +++++++++++++++++++++++++
> > >> 3 files changed, 28 insertions(+), 18 deletions(-)
> > >>
> > >> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> > >> index 69ef077..7ed13e7 100644
> > >> --- a/include/net/bluetooth/l2cap.h
> > >> +++ b/include/net/bluetooth/l2cap.h
> > >> @@ -532,6 +532,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 (*unlink) (struct l2cap_chan *chan, int err);
> > >> };
> > >>
> > >> struct l2cap_conn {
> > >> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > >> index c64da38..d2b16b5 100644
> > >> --- a/net/bluetooth/l2cap_core.c
> > >> +++ b/net/bluetooth/l2cap_core.c
> > >> @@ -520,9 +520,7 @@ 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;
> > >>
> > >> __clear_chan_timer(chan);
> > >>
> > >> @@ -541,22 +539,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
> > >> if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
> > >> goto clean;
> > >>
> > >> - lock_sock(sk);
> > >> -
> > >> - __l2cap_state_change(chan, BT_CLOSED);
> > >> - sock_set_flag(sk, SOCK_ZAPPED);
> > >> -
> > >> - if (err)
> > >> - __l2cap_chan_set_err(chan, err);
> > >> -
> > >> - parent = bt_sk(sk)->parent;
> > >> - if (parent) {
> > >> - bt_accept_unlink(sk);
> > >> - parent->sk_data_ready(parent, 0);
> > >> - } else
> > >> - sk->sk_state_change(sk);
> > >> -
> > >> - release_sock(sk);
> > >> + if (chan->ops->unlink)
> > >> + chan->ops->unlink(chan, err);
> > >>
> > >> if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
> > >> return;
> > >> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > >> index 3bb1611..d6f481b 100644
> > >> --- a/net/bluetooth/l2cap_sock.c
> > >> +++ b/net/bluetooth/l2cap_sock.c
> > >> @@ -955,6 +955,30 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
> > >> return skb;
> > >> }
> > >>
> > >> +static void l2cap_sock_unlink_cb(struct l2cap_chan *chan, int err)
> > >> +{
> > >> + struct sock *sk = chan->sk;
> > >> + struct sock *parent = bt_sk(sk)->parent;
> > >> +
> > >> + lock_sock(sk);
> > >> +
> > >> + chan->state = BT_CLOSED;
> > >> + sk->sk_state = BT_CLOSED;
> > >> + sock_set_flag(sk, SOCK_ZAPPED);
> > >
> > > I think we can improve this code and call it everytime we need to set
> > > SOCK_ZAPPED. We just need a bit more of logic here.
> >
> > We might, if it's not a big of a change. Otherwise I think this kind
> > of change needs to be incremental.
>
> I agree with Ulisses that it shall be incremental since it is not
> straightforward. I am thinking that sock_set_flag(sk, SOCK_ZAPPED) might
> be put before switch in l2cap_chan_close and maybe further. Then we need
> to think about how to make it working for socketless chans...
Check my patch inside the RFC series, it can be done easily.
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-24 8:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-23 8:05 [RFC] Bluetooth: Adds unlink to chan ops Andrei Emeltchenko
2012-05-23 11:03 ` Ulisses Furquim
2012-05-23 20:31 ` Gustavo Padovan
2012-05-23 22:03 ` Ulisses Furquim
2012-05-24 8:18 ` Andrei Emeltchenko
2012-05-24 8:33 ` Gustavo Padovan
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.