NAME

  tst_checksum_no_raw - An attempt to set or get IPV6_CHECKSUM for a non-raw IPv6 socket will fail


PURPOSE

  To check that an attempt to set IPV6_CHECKSUM for an ICMPv6 socket will fail


SYNOPSIS

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


TEST PROCEDURE

  1. Create an IPv6 socket with SOCK_STREAM type
  2. Set the value of IPV6_CHECKSUM option
  3. Check A: An attempt to set IPV6_CHECKSUM will fail
  4. Create an IPv6 socket with SOCK_DGRAM type
  5. Set the value of IPV6_CHECKSUM option
  6. Check B: An attempt to set IPV6_CHECKSUM will fail
  7. Create an IPv6 socket with SOCK_RAW type
  8. Set the value of IPV6_CHECKSUM option for the ICMPv6 socket
  9. Check C: An attempt to set IPV6_CHECKSUM will fail


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