Skip to content

Commit e87a468

Browse files
vyasevichdavem330
authored andcommitted
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: Wolfgang Walter <[email protected]> CC: Wolfgang Walter <[email protected]> CC: Eric Dumazet <[email protected]> Signed-off-by: Vladislav Yasevich <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 91dd93f commit e87a468

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/ipv6/ip6_output.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,10 @@ static int __ip6_append_data(struct sock *sk,
13001300

13011301
/* If this is the first and only packet and device
13021302
* supports checksum offloading, let's use it.
1303+
* Use transhdrlen, same as IPv4, because partial
1304+
* sums only work when transhdrlen is set.
13031305
*/
1304-
if (!skb && sk->sk_protocol == IPPROTO_UDP &&
1306+
if (transhdrlen && sk->sk_protocol == IPPROTO_UDP &&
13051307
length + fragheaderlen < mtu &&
13061308
rt->dst.dev->features & NETIF_F_V6_CSUM &&
13071309
!exthdrlen)

0 commit comments

Comments
 (0)