diff options
author | Simon Vincent <simon.vincent@xsilon.com> | 2014-11-04 10:29:51 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-04 11:31:01 -0500 |
commit | 980edbd503dc0823c75e138edc53a48f99e1e3f6 (patch) | |
tree | f5e93b5623f6453fa4cde8e130c3c1b4a65bfeb5 /net/6lowpan | |
parent | 2a68c897246b70a0c6b51a4a7d48d19b56b3e76b (diff) |
6lowpan: fix udp header compression when using raw sockets
If you use RAW sockets the transport header offset is not set by the
ipv6 stack so when we get to the udp header compression it does not
compress the right part of the packet.
This patch adds a check for this scenario and sets the transport
header offset.
Signed-off-by: Simon Vincent <simon.vincent@xsilon.com>
Acked-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/6lowpan')
-rw-r--r-- | net/6lowpan/iphc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c index 73a7065f0c6b..cd5f8b8e34cd 100644 --- a/net/6lowpan/iphc.c +++ b/net/6lowpan/iphc.c | |||
@@ -512,9 +512,17 @@ static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift, | |||
512 | 512 | ||
513 | static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb) | 513 | static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb) |
514 | { | 514 | { |
515 | struct udphdr *uh = udp_hdr(skb); | 515 | struct udphdr *uh; |
516 | u8 tmp; | 516 | u8 tmp; |
517 | 517 | ||
518 | /* In the case of RAW sockets the transport header is not set by | ||
519 | * the ip6 stack so we must set it ourselves | ||
520 | */ | ||
521 | if (skb->transport_header == skb->network_header) | ||
522 | skb_set_transport_header(skb, sizeof(struct ipv6hdr)); | ||
523 | |||
524 | uh = udp_hdr(skb); | ||
525 | |||
518 | if (((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_MASK) == | 526 | if (((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_MASK) == |
519 | LOWPAN_NHC_UDP_4BIT_PORT) && | 527 | LOWPAN_NHC_UDP_4BIT_PORT) && |
520 | ((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) == | 528 | ((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) == |