tst_checksum_disable - Disabled the IPV6_CHECKSUM socket option to have the kernel not compute and store a checksum
To check that if disabled the IPV6_CHECKSUM option, the kernel will not calculate and store a checksum for outgoing packets, and the kernel will not verify a checksum for received packets.
./tst_checksum_disable [-tooloption ...] -tooloption : v6api tool option
1. Create an IPv6 RAW socket 2. Bind socket to address 3. Send ICMP message to itself with bad checksum 4. Receive ICMP message on socket 5. Check A: Message is received and the bad checksum is not changed by kernel =head1 NOTE
None
RFC 3542
3.1. Checksums
The kernel will calculate and insert the ICMPv6 checksum for ICMPv6 raw sockets, since this checksum is mandatory.
For other raw IPv6 sockets (that is, for raw IPv6 sockets created with a third argument other than IPPROTO_ICMPV6), the application must set the new IPV6_CHECKSUM socket option to have the kernel (1) compute and store a checksum for output, and (2) verify the received checksum on input, discarding the packet if the checksum is in error. This option prevents applications from having to perform source address selection on the packets they send. The checksum will incorporate the IPv6 pseudo-header, defined in Section 8.1 of [RFC- 2460]. This new socket option also specifies an integer offset into the user data of where the checksum is located.
int offset = 2; setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &offset, sizeof(offset));
By default, this socket option is disabled. Setting the offset to -1 also disables the option. By disabled we mean (1) the kernel will not calculate and store a checksum for outgoing packets, and (2) the kernel will not verify a checksum for received packets.
This option assumes the use of the 16-bit one's complement of the one's complement sum as the checksum algorithm and that the checksum field is aligned on a 16-bit boundary. Thus, specifying a positive odd value as offset is invalid, and setsockopt() will fail for such offset values.
An attempt to set IPV6_CHECKSUM for an ICMPv6 socket will fail. Also, an attempt to set or get IPV6_CHECKSUM for a non-raw IPv6 socket will fail.
(Note: Since the checksum is always calculated by the kernel for an ICMPv6 socket, applications are not able to generate ICMPv6 packets with incorrect checksums (presumably for testing purposes) using this API.)