Commit 980edbd5 authored by Simon Vincent's avatar Simon Vincent Committed by Marcel Holtmann

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: default avatarSimon Vincent <simon.vincent@xsilon.com>
Acked-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 2a68c897
...@@ -512,9 +512,17 @@ static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift, ...@@ -512,9 +512,17 @@ static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift,
static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb) static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb)
{ {
struct udphdr *uh = udp_hdr(skb); struct udphdr *uh;
u8 tmp; u8 tmp;
/* In the case of RAW sockets the transport header is not set by
* the ip6 stack so we must set it ourselves
*/
if (skb->transport_header == skb->network_header)
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
uh = udp_hdr(skb);
if (((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_MASK) == if (((ntohs(uh->source) & LOWPAN_NHC_UDP_4BIT_MASK) ==
LOWPAN_NHC_UDP_4BIT_PORT) && LOWPAN_NHC_UDP_4BIT_PORT) &&
((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) == ((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) ==
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment