* [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller
@ 2012-05-09 21:27 Gustavo Padovan
2012-05-09 21:27 ` [PATC -v2 2/2] Bluetooth: Fix skb length calculation Gustavo Padovan
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-09 21:27 UTC (permalink / raw)
To: linux-bluetooth
When building fragmented skb's skb->len keeps track of the size of head
plus all fragments combined, however when queueing the skb for sending we
need to report the head size instead of the total size, so we just set
skb->len to skb_headlen().
This bug appeared when implementing MSG_MORE support for L2CAP sockets, it
never showed up before because l2cap_skbuff_fromiovec() never accounted skb
size correctly. A following patch will fix this.
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
---
net/bluetooth/hci_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a492b374..a7208e8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2162,6 +2162,12 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue,
struct hci_dev *hdev = conn->hdev;
struct sk_buff *list;
+ skb->len = skb_headlen(skb);
+ skb->data_len = 0;
+
+ bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
+ hci_add_acl_hdr(skb, conn->handle, flags);
+
list = skb_shinfo(skb)->frag_list;
if (!list) {
/* Non fragmented */
@@ -2205,8 +2211,6 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags);
skb->dev = (void *) hdev;
- bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
- hci_add_acl_hdr(skb, conn->handle, flags);
hci_queue_acl(conn, &chan->data_q, skb, flags);
--
1.7.10.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATC -v2 2/2] Bluetooth: Fix skb length calculation
2012-05-09 21:27 [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
@ 2012-05-09 21:27 ` Gustavo Padovan
2012-05-09 23:28 ` Mat Martineau
2012-05-09 22:30 ` [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
2012-05-09 23:27 ` Mat Martineau
2 siblings, 1 reply; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-09 21:27 UTC (permalink / raw)
To: linux-bluetooth
When we add a fragment to a skb, len, data_len and truesize fields needs
to be updated.
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
---
net/bluetooth/l2cap_core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 66a1a55..f45f92d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1851,6 +1851,9 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
sent += count;
len -= count;
+ skb->len += (*frag)->len;
+ skb->data_len += (*frag)->len;
+
frag = &(*frag)->next;
}
--
1.7.10.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATC -v2 2/2] Bluetooth: Fix skb length calculation
2012-05-09 21:27 ` [PATC -v2 2/2] Bluetooth: Fix skb length calculation Gustavo Padovan
@ 2012-05-09 23:28 ` Mat Martineau
2012-05-09 23:41 ` Gustavo Padovan
0 siblings, 1 reply; 6+ messages in thread
From: Mat Martineau @ 2012-05-09 23:28 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth
On Wed, 9 May 2012, Gustavo Padovan wrote:
> When we add a fragment to a skb, len, data_len and truesize fields needs
> to be updated.
truesize is not updated in this version of the patch. Also, change
"needs" to "need"
>
> Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
> ---
> net/bluetooth/l2cap_core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 66a1a55..f45f92d 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1851,6 +1851,9 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
> sent += count;
> len -= count;
>
> + skb->len += (*frag)->len;
> + skb->data_len += (*frag)->len;
> +
> frag = &(*frag)->next;
> }
>
> --
> 1.7.10.1
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATC -v2 2/2] Bluetooth: Fix skb length calculation
2012-05-09 23:28 ` Mat Martineau
@ 2012-05-09 23:41 ` Gustavo Padovan
0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-09 23:41 UTC (permalink / raw)
To: Mat Martineau; +Cc: linux-bluetooth
Hi Mat,
* Mat Martineau <mathewm@codeaurora.org> [2012-05-09 16:28:53 -0700]:
>
> On Wed, 9 May 2012, Gustavo Padovan wrote:
>
> >When we add a fragment to a skb, len, data_len and truesize fields needs
> >to be updated.
>
> truesize is not updated in this version of the patch. Also, change
> "needs" to "need"
Thanks for the English fixes in both patches! I'll resend a v3 with those
fixes in.
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller
2012-05-09 21:27 [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
2012-05-09 21:27 ` [PATC -v2 2/2] Bluetooth: Fix skb length calculation Gustavo Padovan
@ 2012-05-09 22:30 ` Gustavo Padovan
2012-05-09 23:27 ` Mat Martineau
2 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2012-05-09 22:30 UTC (permalink / raw)
To: linux-bluetooth
Hah! it should be "PATCH" actually :)
* Gustavo Padovan <gustavo@padovan.org> [2012-05-09 18:27:15 -0300]:
> When building fragmented skb's skb->len keeps track of the size of head
> plus all fragments combined, however when queueing the skb for sending we
> need to report the head size instead of the total size, so we just set
> skb->len to skb_headlen().
>
> This bug appeared when implementing MSG_MORE support for L2CAP sockets, it
> never showed up before because l2cap_skbuff_fromiovec() never accounted skb
> size correctly. A following patch will fix this.
>
> Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
> ---
> net/bluetooth/hci_core.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index a492b374..a7208e8 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2162,6 +2162,12 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue,
> struct hci_dev *hdev = conn->hdev;
> struct sk_buff *list;
>
> + skb->len = skb_headlen(skb);
> + skb->data_len = 0;
> +
> + bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
> + hci_add_acl_hdr(skb, conn->handle, flags);
> +
> list = skb_shinfo(skb)->frag_list;
> if (!list) {
> /* Non fragmented */
> @@ -2205,8 +2211,6 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
> BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags);
>
> skb->dev = (void *) hdev;
> - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
> - hci_add_acl_hdr(skb, conn->handle, flags);
>
> hci_queue_acl(conn, &chan->data_q, skb, flags);
>
> --
> 1.7.10.1
>
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller
2012-05-09 21:27 [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
2012-05-09 21:27 ` [PATC -v2 2/2] Bluetooth: Fix skb length calculation Gustavo Padovan
2012-05-09 22:30 ` [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
@ 2012-05-09 23:27 ` Mat Martineau
2 siblings, 0 replies; 6+ messages in thread
From: Mat Martineau @ 2012-05-09 23:27 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth
On Wed, 9 May 2012, Gustavo Padovan wrote:
> When building fragmented skb's skb->len keeps track of the size of head
> plus all fragments combined, however when queueing the skb for sending we
> need to report the head size instead of the total size, so we just set
> skb->len to skb_headlen().
>
> This bug appeared when implementing MSG_MORE support for L2CAP sockets, it
> never showed up before because l2cap_skbuff_fromiovec() never accounted skb
> size correctly. A following patch will fix this.
>
> Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
> ---
> net/bluetooth/hci_core.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index a492b374..a7208e8 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2162,6 +2162,12 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue,
> struct hci_dev *hdev = conn->hdev;
> struct sk_buff *list;
>
> + skb->len = skb_headlen(skb);
> + skb->data_len = 0;
> +
> + bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
> + hci_add_acl_hdr(skb, conn->handle, flags);
> +
> list = skb_shinfo(skb)->frag_list;
> if (!list) {
> /* Non fragmented */
> @@ -2205,8 +2211,6 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
> BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags);
>
> skb->dev = (void *) hdev;
> - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
> - hci_add_acl_hdr(skb, conn->handle, flags);
>
> hci_queue_acl(conn, &chan->data_q, skb, flags);
>
> --
> 1.7.10.1
Looks fine to me. For the patch title, you might say "Bluetooth: Fix
packet size provided to the controller"
Reviewed-by: Mat Martineau <mathewm@codeaurora.org>
--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-09 23:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 21:27 [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
2012-05-09 21:27 ` [PATC -v2 2/2] Bluetooth: Fix skb length calculation Gustavo Padovan
2012-05-09 23:28 ` Mat Martineau
2012-05-09 23:41 ` Gustavo Padovan
2012-05-09 22:30 ` [PATC -v2 1/2] Bluetooth: Fix packet size informed to the controller Gustavo Padovan
2012-05-09 23:27 ` Mat Martineau
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).