Work around a GCC bug that causes inet_checksum() to give wrong results.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 27 Feb 2018 20:08:57 +0000 (21:08 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 27 Feb 2018 20:08:57 +0000 (21:08 +0100)
commit7c73cb3ace6659df58ec2382b8d47bb521dad886
tree5b8fb066020aed98430c107d4a4cb9a9139e053a
parentd661c7c7353da90911e9f2d0195ac861d6837f5c
Work around a GCC bug that causes inet_checksum() to give wrong results.

Valgrind reports the following bug:

==24877== Conditional jump or move depends on uninitialised value(s)
==24877==    at 0x12283E: inet_checksum (route.c:80)
==24877==    by 0x12283E: route_ipv6_unreachable (route.c:315)
==24877==    by 0x1236AC: route_ipv6 (route.c:751)
==24877==    by 0x1236AC: route (route.c:1160)
==24877==    by 0x113DE0: receive_tcppacket (net_packet.c:493)
==24877==    by 0x1119D4: receive_meta (meta.c:315)
==24877==    by 0x113288: handle_meta_connection_data (net.c:287)
==24877==    by 0x11A091: handle_meta_io (net_socket.c:491)
==24877==    by 0x10FB0C: event_loop (event.c:370)
==24877==    by 0x11362E: main_loop (net.c:489)
==24877==    by 0x10CACA: main (tincd.c:551)

Clearing the variable pseudo in route_ipv6_unreachable removes this error,
but the resulting checksum is still bad. If one instead adds a dummy
write that depends on checksum, the error goes away and the checksum is
correct.
src/route.c