From: Gustavo Padovan <gustavo@padovan.org>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org,
Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: Re: [PATCH -v2 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state
Date: Mon, 28 May 2012 13:36:54 -0300 [thread overview]
Message-ID: <20120528163441.GA18839@joana> (raw)
In-Reply-To: <1338176928.15105.114.camel@aeonflux>
Hi Marcel,
* Marcel Holtmann <marcel@holtmann.org> [2012-05-28 05:48:48 +0200]:
> Hi Gustavo,
>
> > > > 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 3b05f3e..c55b28f 100644
> > > > --- a/include/net/bluetooth/l2cap.h
> > > > +++ b/include/net/bluetooth/l2cap.h
> > > > @@ -599,6 +599,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 01171b1..388bc70 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 = __constant_cpu_to_le16(L2CAP_CR_PEND);
> > > > rsp.status = __constant_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 d2d91b3..51d05a7 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;
> > >
> > > and what about the lines above testing this together with BT_SECURITY?
> >
> > I'm ok with those lines using BT_SK_DEFER_SETUP. CONF_DEFER_SETUP is meant for
> > l2cap_core.c use where we should not have access to sk.
>
> I am not since it is more states we have to keep in sync. That is a bad
> idea. What is the real plan here?
The plan is to remove the use of bt_sk(sk)->flags from l2cap_core.c and the
only idea I had until now was coping the DEFER_SETUP bit to chan->conf_state
flags, however after the copy we can't remove this flags from bt_sk(sk) since
it is used is socket specific doe too.
Gustavo
next prev parent reply other threads:[~2012-05-28 16:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 12:30 [PATCH -v2 00/12] Another step in l2cap_core/sock separation Gustavo Padovan
2012-05-25 12:30 ` [PATCH -v2 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-27 4:59 ` Marcel Holtmann
2012-05-25 12:30 ` [PATCH -v2 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-27 5:00 ` Marcel Holtmann
2012-05-28 6:49 ` Andrei Emeltchenko
2012-05-25 12:30 ` [PATCH -v2 03/12] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
2012-05-27 5:01 ` Marcel Holtmann
2012-05-25 12:30 ` [PATCH -v2 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-27 5:02 ` Marcel Holtmann
2012-05-25 12:30 ` [PATCH -v2 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-27 5:04 ` Marcel Holtmann
2012-05-25 12:30 ` [PATCH -v2 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-25 12:30 ` [PATCH -v2 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-27 5:07 ` Marcel Holtmann
2012-05-27 19:00 ` Gustavo Padovan
2012-05-28 3:48 ` Marcel Holtmann
2012-05-28 16:36 ` Gustavo Padovan [this message]
2012-05-25 12:31 ` [PATCH -v2 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
2012-05-27 5:08 ` Marcel Holtmann
2012-05-25 12:31 ` [PATCH -v2 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-27 5:09 ` Marcel Holtmann
2012-05-25 12:31 ` [PATCH -v2 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-25 16:18 ` Mat Martineau
2012-05-25 12:31 ` [PATCH -v2 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-25 12:31 ` [PATCH -v2 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
2012-05-25 12:39 ` Andrei Emeltchenko
2012-05-25 12:41 ` Gustavo Padovan
2012-05-27 5:11 ` 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=20120528163441.GA18839@joana \
--to=gustavo@padovan.org \
--cc=gustavo.padovan@collabora.co.uk \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.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;
as well as URLs for NNTP newsgroup(s).