Skip to content

Commit

Permalink
6lowpan: Uncompression of traffic class field was incorrect
Browse files Browse the repository at this point in the history
If priority/traffic class field in IPv6 header is set (seen when
using ssh), the uncompression sets the TC and Flow fields incorrectly.

Example:

This is IPv6 header of a sent packet. Note the priority/TC (=1) in
the first byte.

00000000: 61 00 00 00 00 2c 06 40 fe 80 00 00 00 00 00 00
00000010: 02 02 72 ff fe c6 42 10 fe 80 00 00 00 00 00 00
00000020: 02 1e ab ff fe 4c 52 57

This gets compressed like this in the sending side

00000000: 72 31 04 06 02 1e ab ff fe 4c 52 57 ec c2 00 16
00000010: aa 2d fe 92 86 4e be c6 ....

In the receiving end, the packet gets uncompressed to this
IPv6 header

00000000: 60 06 06 02 00 2a 1e 40 fe 80 00 00 00 00 00 00
00000010: 02 02 72 ff fe c6 42 10 fe 80 00 00 00 00 00 00
00000020: ab ff fe 4c 52 57 ec c2

First four bytes are set incorrectly and we have also lost
two bytes from destination address.

The fix is to switch the case values in switch statement
when checking the TC field.

Signed-off-by: Jukka Rissanen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jukkar authored and davem330 committed Nov 15, 2013
1 parent 3db0a19 commit 1188f05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/ieee802154/6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ lowpan_process_data(struct sk_buff *skb)
* Traffic class carried in-line
* ECN + DSCP (1 byte), Flow Label is elided
*/
case 1: /* 10b */
case 2: /* 10b */
if (lowpan_fetch_skb_u8(skb, &tmp))
goto drop;

Expand All @@ -967,7 +967,7 @@ lowpan_process_data(struct sk_buff *skb)
* Flow Label carried in-line
* ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided
*/
case 2: /* 01b */
case 1: /* 01b */
if (lowpan_fetch_skb_u8(skb, &tmp))
goto drop;

Expand Down

0 comments on commit 1188f05

Please sign in to comment.