* [PATCHv2 bluetooth-next] 6lowpan: fix udp header compression when using raw sockets
@ 2014-11-04 14:34 Simon Vincent
2014-11-04 14:42 ` Alexander Aring
0 siblings, 1 reply; 3+ messages in thread
From: Simon Vincent @ 2014-11-04 14:34 UTC (permalink / raw)
To: alex.aring; +Cc: linux-wpan, linux-bluetooth, Simon Vincent
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>
---
net/6lowpan/iphc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 73a7065..305bf2b 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,
static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb)
{
- struct udphdr *uh = udp_hdr(skb);
+ struct udphdr *uh;
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) ==
LOWPAN_NHC_UDP_4BIT_PORT) &&
((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) ==
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCHv2 bluetooth-next] 6lowpan: fix udp header compression when using raw sockets
2014-11-04 14:34 [PATCHv2 bluetooth-next] 6lowpan: fix udp header compression when using raw sockets Simon Vincent
@ 2014-11-04 14:42 ` Alexander Aring
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Aring @ 2014-11-04 14:42 UTC (permalink / raw)
To: Simon Vincent; +Cc: linux-wpan, linux-bluetooth
On Tue, Nov 04, 2014 at 02:34:53PM +0000, Simon Vincent wrote:
> 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>
> ---
> net/6lowpan/iphc.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
> index 73a7065..305bf2b 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,
>
> static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb)
> {
> - struct udphdr *uh = udp_hdr(skb);
> + struct udphdr *uh;
> u8 tmp;
>
> + /* In the case of RAW sockets the transport header is not set by
> + * the ip6 stack so we must set it ourselves
> + */
Should be:
/* In the case of RAW sockets the transport header is not set by
* the ip6 stack so we must set it ourselves
*/
Otherwise looking good! ;-)
- Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCHv2 bluetooth-next] 6lowpan: fix udp header compression when using raw sockets
@ 2014-11-04 14:48 Simon Vincent
0 siblings, 0 replies; 3+ messages in thread
From: Simon Vincent @ 2014-11-04 14:48 UTC (permalink / raw)
To: alex.aring; +Cc: linux-wpan, linux-bluetooth, Simon Vincent
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>
---
net/6lowpan/iphc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 73a7065..305bf2b 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,
static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb)
{
- struct udphdr *uh = udp_hdr(skb);
+ struct udphdr *uh;
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) ==
LOWPAN_NHC_UDP_4BIT_PORT) &&
((ntohs(uh->dest) & LOWPAN_NHC_UDP_4BIT_MASK) ==
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-04 14:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 14:34 [PATCHv2 bluetooth-next] 6lowpan: fix udp header compression when using raw sockets Simon Vincent
2014-11-04 14:42 ` Alexander Aring
-- strict thread matches above, loose matches on Subject: below --
2014-11-04 14:48 Simon Vincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).