tst_recv_dst_addr_tcp - Receiving Destination Address (TCP socket)
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
./tst_recv_dst_addr_tcp [-tooloption ...] -tooloption : v6api tool option
1. Create tcp socket for tcp server 2. Create tcp socket for tcp client 3. Enable tcp client to receive destination address 4. Bind tcp server socket to address 5. Listen on tcp server socket 6. Connect tcp client to tcp server 7. Accept a connection on tcp server 8. Send message from tcp server to tcp client 9. Recv message from tcp server on tcp client 10.Get the value of IPV6_PKTOPTIONS option of tcp client used getsockopt() 11.Check A: Check whether packet information is returned 12.Check B: The received value and length of destination address is correct 13.Close the tcp client 14.Create tcp socket for tcp client 15.Enable tcp client to receive destination address 16.Get the value of IPV6_PKTOPTIONS option of tcp client used getsockopt() 17.Check C: Check whether packet information is returned 18.Check D: The received value and length of destination address is correct
None
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.