NAME

  tst_recv_dst_addr_udp - Receive Destination Address when the IPV6_RECVPKTINFO socket option is enabled


PURPOSE

  To check that when the IPV6_RECVPKTINFO socket option is enabled, the
  received destination address is always returned as the ipi6_ifindex 
  member of the in6_pktinfo structure


SYNOPSIS

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


TEST PROCEDURE

  1. Create an IPv6/UDP socket
  2. Enable the socket to receive destination address
  3. Bind the socket to address
  4. Send one message to itself
  5. Receive one message used recvmsg()
  6. Check A: Check whether packet information is returned
  7. Check B: The received value and length of destination address is correct


NOTE

  None


REFERENCE

  RFC 3542
  6.2.  Specifying/Receiving Source/Destination Address
    The source IPv6 address can be specified by calling bind() before
    each output operation, but supplying the source address together with
    the data requires less overhead (i.e., fewer system calls) and
    requires less state to be stored and protected in a multithreaded
    application.
    When specifying the source IPv6 address as ancillary data, if the
    ipi6_addr member of the in6_pktinfo structure is the unspecified
    address (IN6ADDR_ANY_INIT or in6addr_any), then (a) if an address is
    currently bound to the socket, it is used as the source address, or
    (b) if no address is currently bound to the socket, the kernel will
    choose the source address.  If the ipi6_addr member is not the
    unspecified address, but the socket has already bound a source
    address, then the ipi6_addr value overrides the already-bound source
    address for this output operation only.
    The kernel must verify that the requested source address is indeed a
    unicast address assigned to the node.  When the address is a scoped
    one, there may be ambiguity about its scope zone.  This is
    particularly the case for link-local addresses.  In such a case, the
    kernel must first determine the appropriate scope zone based on the
    zone of the destination address or the outgoing interface (if known),
    then qualify the address.  This also means that it is not feasible to
    specify the source address for a non-binding socket by the
    IPV6_PKTINFO sticky option, unless the outgoing interface is also
    specified.  The application should simply use bind() for such
    purposes.
    IPV6_PKTINFO can also be used as a sticky option for specifying the
    socket's default source address.  However, the ipi6_addr member must
    be the unspecified address for TCP sockets, because it is not
    possible to dynamically change the source address of a TCP
    connection.  When the IPV6_PKTINFO option is specified for a TCP
    socket with a non-unspecified address, the call will fail.  This
    restriction should be applied even before the socket binds a specific
    address.
    When the in6_pktinfo structure is returned as ancillary data by
    recvmsg(), the ipi6_addr member contains the destination IPv6 address
    from the received packet.