public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathewm@codeaurora.org>
To: Gustavo Padovan <gustavo@padovan.org>
Cc: linux-bluetooth@vger.kernel.org,
	Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: Re: [RFC 8/8] Bluetooth: Add chan->ops->authorize
Date: Thu, 24 May 2012 10:10:28 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.02.1205241000160.18142@mathewm-linux> (raw)
In-Reply-To: <1337821964-4618-9-git-send-email-gustavo@padovan.org>


Gustavo -

On Wed, 23 May 2012, Gustavo Padovan wrote:

> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> When DEFER_SETUP is set authorize() 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 4f81d08..94e375a 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			(*authorize) (void *data);
> };

I'm trying to think of a name more specific to the deferred connection 
feature than "authorize"...  There's a lot of use of "auth" to refer 
to "authentication", so it could be confusing to throw "authorize" in 
to the mix.

"deferred_connect"? 
"pending_connection"?
"defer"?

>
> struct l2cap_conn {
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 1305b3b..22ba699 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->authorize)
> +						chan->ops->authorize(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->authorize)
> +					chan->ops->authorize(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->authorize)
> +						chan->ops->authorize(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 dac7b2c..d2a81f1 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -1047,6 +1047,17 @@ static void l2cap_sock_ready_cb(void *data)
> 	release_sock(sk);
> }
>
> +static void l2cap_sock_authorize_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,
> @@ -1056,6 +1067,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,
> +	.authorize	= l2cap_sock_authorize_cb,
> };
>
> static void l2cap_sock_destruct(struct sock *sk)
> -- 
> 1.7.10.1


--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


  parent reply	other threads:[~2012-05-24 17:10 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24  1:12 [RFC 0/8] Another step in l2cap_core/sock separation Gustavo Padovan
2012-05-24  1:12 ` [RFC 1/8] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24  1:12   ` [RFC 2/8] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24  1:12     ` [RFC 3/8] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
2012-05-24  1:12       ` [RFC 4/8] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-24  1:12         ` [RFC 5/8] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-24  1:12           ` [RFC 6/8] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-24  1:12             ` [RFC 7/8] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-24  1:12               ` [RFC 8/8] Bluetooth: Add chan->ops->authorize Gustavo Padovan
2012-05-24  6:02                 ` [RFC 1/3] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24  6:02                   ` [RFC 2/3] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24  6:02                     ` [RFC 3/3] Blueooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24  6:32                       ` Gustavo Padovan
2012-05-24  7:00                       ` [RFC 1/2] Bluetooth: Create chan->ops->set_err() Gustavo Padovan
2012-05-24  7:00                         ` [RFC 2/2] Bluetooth: Remove last usage of sk->sk_state_change() Gustavo Padovan
2012-05-24  8:30                           ` Andrei Emeltchenko
2012-05-24 17:06                             ` Gustavo Padovan
2012-05-24  8:26                         ` [RFC 1/2] Bluetooth: Create chan->ops->set_err() Andrei Emeltchenko
2012-05-24 17:04                           ` Gustavo Padovan
2012-05-24 17:18                             ` Mat Martineau
2012-05-25  7:07                               ` Andrei Emeltchenko
2012-05-24  9:22                       ` [RFC 3/3] Blueooth: Remove parent socket usage from l2cap_core.c Andrei Emeltchenko
2012-05-24  9:24                     ` [RFC 2/3] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Andrei Emeltchenko
2012-05-24 17:09                       ` Gustavo Padovan
2012-05-24 17:36                     ` Mat Martineau
2012-05-24  9:27                   ` [RFC 1/3] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko
2012-05-24  9:55                 ` [RFC 8/8] Bluetooth: Add chan->ops->authorize Andrei Emeltchenko
2012-05-24 17:08                   ` Gustavo Padovan
2012-05-24 17:10                 ` Mat Martineau [this message]
2012-05-24  9:50               ` [RFC 7/8] Bluetooth: Create DEFER_SETUP flag in conf_state Andrei Emeltchenko
2012-05-24 17:01                 ` Gustavo Padovan
2012-05-24  9:45             ` [RFC 6/8] Bluetooth: Move check for backlog size to l2cap_sock.c Andrei Emeltchenko
2012-05-24 16:57               ` Gustavo Padovan
2012-05-24  9:39       ` [RFC 3/8] Bluetooth: Add l2cap_chan->ops->ready() Andrei Emeltchenko
2012-05-24 10:23         ` Andrei Emeltchenko
2012-05-24 11:17           ` Ulisses Furquim
2012-05-24 11:30             ` Andrei Emeltchenko
2012-05-24 11:31               ` Ulisses Furquim
2012-05-24 11:37                 ` Andrei Emeltchenko
2012-05-24 17:48                   ` Mat Martineau
2012-05-24 17:53                     ` Ulisses Furquim
2012-05-24 18:48               ` Vinicius Costa Gomes
2012-05-24  9:38     ` [RFC 2/8] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Andrei Emeltchenko
2012-05-24  9:35   ` [RFC 1/8] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Andrei Emeltchenko
2012-05-24 16:56     ` Gustavo Padovan
2012-05-24 17:14       ` Gustavo Padovan
2012-05-24 17:25         ` Vinicius Costa Gomes
2012-05-24  6:12 ` [RFC 0/8] Another step in l2cap_core/sock separation Gustavo Padovan
2012-05-24 10:02 ` Andrei Emeltchenko
2012-05-24 16:43   ` Gustavo Padovan
2012-05-24 17:55   ` Mat Martineau

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=alpine.DEB.2.02.1205241000160.18142@mathewm-linux \
    --to=mathewm@codeaurora.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=gustavo@padovan.org \
    --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