* [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link
@ 2009-02-28 5:02 Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28 5:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: linux-kernel
fix race condition
Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
net/bluetooth/l2cap.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index ca4d3b4..355f375 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -175,12 +175,14 @@ static inline void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
{
sock_hold(sk);
+ write_lock_bh(&l->lock);
if (l->head)
l2cap_pi(l->head)->prev_c = sk;
l2cap_pi(sk)->next_c = l->head;
l2cap_pi(sk)->prev_c = NULL;
l->head = sk;
+ write_unlock_bh(&l->lock);
}
static inline void l2cap_chan_unlink(struct l2cap_chan_list *l, struct sock *sk)
--
1.6.0.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] bluetooth: add macros for cid channel numbers
2009-02-28 5:02 [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
@ 2009-02-28 5:02 ` Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 3/3] bluetooth: use L2CAP_CID_* macros Gustavo F. Padovan
2009-02-28 21:30 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Marcel Holtmann
2009-02-28 5:54 ` [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
2009-02-28 21:33 ` Marcel Holtmann
2 siblings, 2 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28 5:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: linux-kernel
Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
include/net/bluetooth/l2cap.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f566aa1..e7bf331 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -118,6 +118,13 @@ struct l2cap_conn_rsp {
#define L2CAP_CS_AUTHEN_PEND 0x0001
#define L2CAP_CS_AUTHOR_PEND 0x0002
+
+/* cid channel type */
+#define L2CAP_CID_SIGNALING 0x0001
+#define L2CAP_CID_CONN_LESS 0x0002
+#define L2CAP_CID_DYN_START 0x0040
+#define L2CAP_CID_DYN_END 0xffff
+
struct l2cap_conf_req {
__le16 dcid;
__le16 flags;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] bluetooth: use L2CAP_CID_* macros
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
@ 2009-02-28 5:02 ` Gustavo F. Padovan
2009-02-28 21:31 ` Marcel Holtmann
2009-02-28 21:30 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Marcel Holtmann
1 sibling, 1 reply; 8+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28 5:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: linux-kernel
Use macros instead of hardcoded numbers
Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
net/bluetooth/l2cap.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 355f375..6181fc8 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -161,9 +161,9 @@ static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8
static u16 l2cap_alloc_cid(struct l2cap_chan_list *l)
{
- u16 cid = 0x0040;
+ u16 cid = L2CAP_CID_DYN_START;
- for (; cid < 0xffff; cid++) {
+ for (; cid < L2CAP_CID_DYN_END; cid++) {
if(!__l2cap_get_chan_by_scid(l, cid))
return cid;
}
@@ -217,13 +217,13 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
l2cap_pi(sk)->scid = l2cap_alloc_cid(l);
} else if (sk->sk_type == SOCK_DGRAM) {
/* Connectionless socket */
- l2cap_pi(sk)->scid = 0x0002;
- l2cap_pi(sk)->dcid = 0x0002;
+ l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS;
+ l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS;
l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU;
} else {
/* Raw socket can send/recv signalling messages only */
- l2cap_pi(sk)->scid = 0x0001;
- l2cap_pi(sk)->dcid = 0x0001;
+ l2cap_pi(sk)->scid = L2CAP_CID_SIGNALING;
+ l2cap_pi(sk)->dcid = L2CAP_CID_SIGNALING;
l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU;
}
@@ -1600,7 +1600,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen);
- lh->cid = cpu_to_le16(0x0001);
+ lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE);
cmd->code = code;
@@ -2422,11 +2422,11 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("len %d, cid 0x%4.4x", len, cid);
switch (cid) {
- case 0x0001:
+ case L2CAP_CID_SIGNALING:
l2cap_sig_channel(conn, skb);
break;
- case 0x0002:
+ case L2CAP_CID_CONN_LESS:
psm = get_unaligned((__le16 *) skb->data);
skb_pull(skb, 2);
l2cap_conless_channel(conn, psm, skb);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link
2009-02-28 5:02 [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
@ 2009-02-28 5:54 ` Gustavo F. Padovan
2009-02-28 21:33 ` Marcel Holtmann
2 siblings, 0 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28 5:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: linux-kernel
On Sat, Feb 28, 2009 at 2:02 AM, Gustavo F. Padovan
<gustavo@las.ic.unicamp.br> wrote:
> fix race condition
>
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
> ---
> net/bluetooth/l2cap.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index ca4d3b4..355f375 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -175,12 +175,14 @@ static inline void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
> {
> sock_hold(sk);
>
> + write_lock_bh(&l->lock);
> if (l->head)
> l2cap_pi(l->head)->prev_c = sk;
>
> l2cap_pi(sk)->next_c = l->head;
> l2cap_pi(sk)->prev_c = NULL;
> l->head = sk;
> + write_unlock_bh(&l->lock);
> }
>
> static inline void l2cap_chan_unlink(struct l2cap_chan_list *l, struct sock *sk)
This patch is wrong, ignore it.
> --
> 1.6.0.6
>
> --
> 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
>
--
Gustavo F. Padovan
Computer Engineering Student
Institute of Computing - IC
University of Campinas - UNICAMP
email: gustavo@las.ic.unicamp.br
gtalk: gfpadovan@gmail.com
mobile: +55 19 81030803
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] bluetooth: add macros for cid channel numbers
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 3/3] bluetooth: use L2CAP_CID_* macros Gustavo F. Padovan
@ 2009-02-28 21:30 ` Marcel Holtmann
1 sibling, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2009-02-28 21:30 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth, linux-kernel
Hi Gustavo,
you can keep Bluetooth patches on linux-bluetooth only since they have
to go via bluetooth-testing.git first.
You are missing a commit message before the signed-off-by line. I am
serious about that every kernel patch has a proper commit message in
human readable text. No matter how simple the patch might look.
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
> ---
> include/net/bluetooth/l2cap.h | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index f566aa1..e7bf331 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -118,6 +118,13 @@ struct l2cap_conn_rsp {
> #define L2CAP_CS_AUTHEN_PEND 0x0001
> #define L2CAP_CS_AUTHOR_PEND 0x0002
>
> +
> +/* cid channel type */
Use /* channel identifier */ here.
> +#define L2CAP_CID_SIGNALING 0x0001
> +#define L2CAP_CID_CONN_LESS 0x0002
> +#define L2CAP_CID_DYN_START 0x0040
> +#define L2CAP_CID_DYN_END 0xffff
> +
And put these above /* connect result */ defs.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] bluetooth: use L2CAP_CID_* macros
2009-02-28 5:02 ` [PATCH 3/3] bluetooth: use L2CAP_CID_* macros Gustavo F. Padovan
@ 2009-02-28 21:31 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2009-02-28 21:31 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth, linux-kernel
Hi Gustavo,
> Use macros instead of hardcoded numbers
combine this with your previous patch and get me a proper commit
message.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link
2009-02-28 5:02 [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
2009-02-28 5:54 ` [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
@ 2009-02-28 21:33 ` Marcel Holtmann
2009-02-28 21:49 ` Gustavo F. Padovan
2 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2009-02-28 21:33 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth, linux-kernel
Hi Gustavo,
> fix race condition
>
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
> ---
> net/bluetooth/l2cap.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index ca4d3b4..355f375 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -175,12 +175,14 @@ static inline void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
> {
> sock_hold(sk);
>
> + write_lock_bh(&l->lock);
> if (l->head)
> l2cap_pi(l->head)->prev_c = sk;
>
> l2cap_pi(sk)->next_c = l->head;
> l2cap_pi(sk)->prev_c = NULL;
> l->head = sk;
> + write_unlock_bh(&l->lock);
> }
a general rule of thumb is that function starting with __ are the ones
that don't use any kind of locking.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link
2009-02-28 21:33 ` Marcel Holtmann
@ 2009-02-28 21:49 ` Gustavo F. Padovan
0 siblings, 0 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2009-02-28 21:49 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth, linux-kernel
On Sat, Feb 28, 2009 at 6:33 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Gustavo,
>
>> fix race condition
>>
>> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
>> ---
>> net/bluetooth/l2cap.c | 2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>> index ca4d3b4..355f375 100644
>> --- a/net/bluetooth/l2cap.c
>> +++ b/net/bluetooth/l2cap.c
>> @@ -175,12 +175,14 @@ static inline void __l2cap_chan_link(struct l2cap_chan_list *l, struct sock *sk)
>> {
>> sock_hold(sk);
>>
>> + write_lock_bh(&l->lock);
>> if (l->head)
>> l2cap_pi(l->head)->prev_c = sk;
>>
>> l2cap_pi(sk)->next_c = l->head;
>> l2cap_pi(sk)->prev_c = NULL;
>> l->head = sk;
>> + write_unlock_bh(&l->lock);
>> }
>
> a general rule of thumb is that function starting with __ are the ones
> that don't use any kind of locking.
Ok. I noted this after send the patch. :-(
>
> Regards
>
> Marcel
>
>
>
--
Gustavo F. Padovan
Computer Engineering Student
Institute of Computing - IC
University of Campinas - UNICAMP
email: gustavo@las.ic.unicamp.br
gtalk: gfpadovan@gmail.com
mobile: +55 19 81030803
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-02-28 21:49 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-28 5:02 [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Gustavo F. Padovan
2009-02-28 5:02 ` [PATCH 3/3] bluetooth: use L2CAP_CID_* macros Gustavo F. Padovan
2009-02-28 21:31 ` Marcel Holtmann
2009-02-28 21:30 ` [PATCH 2/3] bluetooth: add macros for cid channel numbers Marcel Holtmann
2009-02-28 5:54 ` [PATCH 1/3] bluetooth: add write_lock_bh to __l2cap_chan_link Gustavo F. Padovan
2009-02-28 21:33 ` Marcel Holtmann
2009-02-28 21:49 ` Gustavo F. Padovan
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).