Commit e87a468e authored by Vlad Yasevich's avatar Vlad Yasevich Committed by David S. Miller

ipv6: Fix udp checksums with raw sockets

It was reported that trancerout6 would cause
a kernel to crash when trying to compute checksums
on raw UDP packets.  The cause was the check in
__ip6_append_data that would attempt to use
partial checksums on the packet.  However,
raw sockets do not initialize partial checksum
fields so partial checksums can't be used.

Solve this the same way IPv4 does it.  raw sockets
pass transhdrlen value of 0 to ip_append_data which
causes the checksum to be computed in software.  Use
the same check in ip6_append_data (check transhdrlen).
Reported-by: default avatarWolfgang Walter <linux@stwm.de>
CC: Wolfgang Walter <linux@stwm.de>
CC: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarVladislav Yasevich <vyasevic@redhat.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 91dd93f9
...@@ -1300,8 +1300,10 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1300,8 +1300,10 @@ static int __ip6_append_data(struct sock *sk,
/* If this is the first and only packet and device /* If this is the first and only packet and device
* supports checksum offloading, let's use it. * supports checksum offloading, let's use it.
* Use transhdrlen, same as IPv4, because partial
* sums only work when transhdrlen is set.
*/ */
if (!skb && sk->sk_protocol == IPPROTO_UDP && if (transhdrlen && sk->sk_protocol == IPPROTO_UDP &&
length + fragheaderlen < mtu && length + fragheaderlen < mtu &&
rt->dst.dev->features & NETIF_F_V6_CSUM && rt->dst.dev->features & NETIF_F_V6_CSUM &&
!exthdrlen) !exthdrlen)
......
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