6lowpan: Fix extraction of flow label field
authorLukasz Duda <lukasz.duda@nordicsemi.no>
Mon, 10 Aug 2015 19:15:52 +0000 (21:15 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 10 Aug 2015 18:43:05 +0000 (20:43 +0200)
The lowpan_fetch_skb function is used to fetch the first byte,
which also increments the data pointer in skb structure,
making subsequent array lookup of byte 0 actually being byte 1.

To decompress the first byte of the Flow Label when the TF flag is
set to 0x01, the second half of the first byte is needed.

The patch fixes the extraction of the Flow Label field.

Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
Signed-off-by: Glenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no>
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/6lowpan/iphc.c

index 9055d7b9d1129d69e34f8ed255922b2e340fcbb1..74e56d7449c8d6183bd60aeeb19ccde401f4b773 100644 (file)
@@ -284,7 +284,7 @@ lowpan_header_decompress(struct sk_buff *skb, struct net_device *dev,
                if (lowpan_fetch_skb(skb, &tmp, sizeof(tmp)))
                        return -EINVAL;
 
-               hdr.flow_lbl[0] = (skb->data[0] & 0x0F) | ((tmp >> 2) & 0x30);
+               hdr.flow_lbl[0] = (tmp & 0x0F) | ((tmp >> 2) & 0x30);
                memcpy(&hdr.flow_lbl[1], &skb->data[0], 2);
                skb_pull(skb, 2);
                break;