All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue
@ 2015-08-24 16:57 Loic Poulain
  2015-08-24 18:19 ` Marcel Holtmann
  2015-08-25 15:02 ` Marcel Holtmann
  0 siblings, 2 replies; 5+ messages in thread
From: Loic Poulain @ 2015-08-24 16:57 UTC (permalink / raw)
  To: marcel, johan.hedberg; +Cc: linux-bluetooth, Loic Poulain

Packets with a variable len equal to zero were not received.
Since no more data expected (and input buffer entirely consumed), we
need to complete/forward the packet immediately instead of waiting for
more data.

Fix this by completing the packet on !dlen.
happening if two cases:
    - no variable data len
    - variable data len is zero.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
---
 drivers/bluetooth/hci_h4.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 57faddc..5bd8301 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -223,8 +223,7 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 			switch ((&pkts[i])->lsize) {
 			case 0:
 				/* No variable data length */
-				(&pkts[i])->recv(hdev, skb);
-				skb = NULL;
+				dlen = 0;
 				break;
 			case 1:
 				/* Single octet variable length */
@@ -252,6 +251,12 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 				kfree_skb(skb);
 				return ERR_PTR(-EILSEQ);
 			}
+
+			if (!dlen) {
+				/* no more data, complete frame */
+				(&pkts[i])->recv(hdev, skb);
+				skb = NULL;
+			}
 		} else {
 			/* Complete frame */
 			(&pkts[i])->recv(hdev, skb);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue
  2015-08-24 16:57 [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue Loic Poulain
@ 2015-08-24 18:19 ` Marcel Holtmann
  2015-08-25  8:09   ` Loic Poulain
  2015-08-25 15:02 ` Marcel Holtmann
  1 sibling, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2015-08-24 18:19 UTC (permalink / raw)
  To: Loic Poulain; +Cc: Johan Hedberg, linux-bluetooth

Hi Loic,

> Packets with a variable len equal to zero were not received.
> Since no more data expected (and input buffer entirely consumed), we
> need to complete/forward the packet immediately instead of waiting for
> more data.
> 
> Fix this by completing the packet on !dlen.
> happening if two cases:
>    - no variable data len
>    - variable data len is zero.

please give me an example of such a packet. I am currently failing to see what is wrong with the code and how this patch would actually help.

Is this for vendor packet types or does this actually happen with standard H:4 packet types?

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue
  2015-08-24 18:19 ` Marcel Holtmann
@ 2015-08-25  8:09   ` Loic Poulain
  2015-08-25 15:01     ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Loic Poulain @ 2015-08-25  8:09 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Johan Hedberg, linux-bluetooth

Hi Marcel,


> please give me an example of such a packet. I am currently failing to see what is wrong with the code and how this patch would actually help.
>
> Is this for vendor packet types or does this actually happen with standard H:4 packet types?


Yes, this is for some vendor specific packets.
For example, I have to deal with LPM packet with the following format:

|0xf1|opcode|dlen|data|

This kind of packet can be easily added to the h4_recv_pkt list.
However, some of these packets don't have any data (just PM ack packet):
0xf1|0x03|0x00

If we receive this packet, the h4_recv_buf function will retrieve the 
dlen (0) and just wait for more data. As long as there is not new data 
received (new packet), the LPM packet is not transmitted to the bt core.

Regards,
Loic


-- 
Intel Open Source Technology Center
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue
  2015-08-25  8:09   ` Loic Poulain
@ 2015-08-25 15:01     ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2015-08-25 15:01 UTC (permalink / raw)
  To: Loic Poulain; +Cc: Johan Hedberg, linux-bluetooth

Hi Loic,

>> please give me an example of such a packet. I am currently failing to see what is wrong with the code and how this patch would actually help.
>> 
>> Is this for vendor packet types or does this actually happen with standard H:4 packet types?
> 
> 
> Yes, this is for some vendor specific packets.
> For example, I have to deal with LPM packet with the following format:
> 
> |0xf1|opcode|dlen|data|
> 
> This kind of packet can be easily added to the h4_recv_pkt list.
> However, some of these packets don't have any data (just PM ack packet):
> 0xf1|0x03|0x00
> 
> If we receive this packet, the h4_recv_buf function will retrieve the dlen (0) and just wait for more data. As long as there is not new data received (new packet), the LPM packet is not transmitted to the bt core.

so the part that confused me is when you said, that you are fixing this for no variable data length. That part is actually not broken. There you just re-order the code.

Regards

Marcel



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue
  2015-08-24 16:57 [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue Loic Poulain
  2015-08-24 18:19 ` Marcel Holtmann
@ 2015-08-25 15:02 ` Marcel Holtmann
  1 sibling, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2015-08-25 15:02 UTC (permalink / raw)
  To: Loic Poulain; +Cc: Johan Hedberg, linux-bluetooth

Hi Loic,

> Packets with a variable len equal to zero were not received.
> Since no more data expected (and input buffer entirely consumed), we
> need to complete/forward the packet immediately instead of waiting for
> more data.
> 
> Fix this by completing the packet on !dlen.
> happening if two cases:
>    - no variable data len
>    - variable data len is zero.
> 
> Signed-off-by: Loic Poulain <loic.poulain@intel.com>
> ---
> drivers/bluetooth/hci_h4.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)

I updated the commit message slightly and then applied the patch to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-25 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 16:57 [PATCH] Bluetooth: hci_h4: Fix zero len data packet reception issue Loic Poulain
2015-08-24 18:19 ` Marcel Holtmann
2015-08-25  8:09   ` Loic Poulain
2015-08-25 15:01     ` Marcel Holtmann
2015-08-25 15:02 ` Marcel Holtmann

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.