NAME

  tst_checksum_enable - Set the IPV6_CHECKSUM socket option to have the kernel compute and store a checksum


PURPOSE

  To check that if IPV6_CHECKSUM option is set, the kernel
  compute and store a checksum for output, and verify the 
  received checksum on input, discarding the packet if the
  checksum is in error.


SYNOPSIS

  ./tst_checksum_enable [-tooloption ...]
    -tooloption : v6api tool option


TEST PROCEDURE

  1. Create an IPv6 RAW socket
  2. Set the value of IPV6_CHECKSUM option to odd value
  3. Check A: Fail to set value of IPV6_CHECKSUM option
  4. Bind socket to address
  5. Send ICMP message to itself
  6. Receive ICMP message on socket
  7. Check B: Message is received and the checksum is not changed by kernel
  8. Set the value of IPV6_CHECKSUM option to 2
  9. Send ICMP message to itself
  10.Receive ICMP message on socket
  11.Check C: Message is received and the checksum is changed by kernel
  12.Create another IPv6 RAW socket
  13.Bind the socket to address
  14.Send ICMP message from the first socket
  15.Receive ICMP message on the socket
  16.Check D: Message is received and the checksum is changed by kernel
  17.Set the value of IPV6_CHECKSUM option to 4
  18.Send ICMP message from the first socket
  19.Receive ICMP message on socket
  20.Check E: Message can not be received on socket


NOTE

  None


REFERENCE

  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.)