6lowpan: Fix extraction of flow label field

This change “6lowpan: Fix extraction of flow label field” in Linux kernel is authored by Lukasz Duda <lukasz.duda [at] nordicsemi.no> on Mon Aug 10 21:15:52 2015 +0200.

6lowpan: Fix extraction of flow label field

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>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 77e867b.

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/6lowpan/iphc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 9055d7b..74e56d7 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -284,7 +284,7 @@ static int lowpan_uncompress_multicast_daddr(struct sk_buff *skb,
 		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);

The commit for this change in Linux stable tree is 77e867b (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *