IP_RECVDSTADDR & IP_SENDSRCADDR have not been implemented for IPv6. When using systems with multiple IP addresses (esp. multiple alias addresses tied to the same physical NIC) for serving UDP requests these options are currently the only method for ensuring the source addresses for responses to requests received via a wildcard bound socket match the addresses to which the original requests were sent. For IPv6 these options do not seem to work, though, for IPv4 they have been implemented. With IPv6 one NIC practically always has multiple IPv6 addresses, and thus the need for nailing down the correct source address for outbound packets is needed even more than for IPv4. With IPv6 there is no way avoiding the system randomly selecting whatever local address as the source address based on which address happens to be the first on a NIC's list of alias addresses when sending outbound packets unless one binds a separate socket to each local address in advance. Binding multiple local addresses is harmful, though, because programs do not continuously scan the local IP addresses. Fix: In short term: Add support for IP_RECVDSTADDR & IP_SENDSRCADDR also to IPv6. (This is a bug fix - correcting asymmentry between IPv4 and IPv6.) In long term: Add support for listen() & accept() for UDP thus allowing nailing down a particular local socket address for the new socket created by accept() and allowing the original wildcard bound listen socket wait for packets sent to any other local address. (This is actually a change request.) How-To-Repeat: Modify e.g. a simple UDP based echo program to use setsockopt(), recvmsg(), and sendmsg() with IP_RECVDSTADDR & IP_SENDSRCADDR instead of recvfrom() and sendto(). When using UDP/IPv4 these socket options seem to work just fine, though, using them is somewhat too hairy for the average network programmer. When using UDP/IPv6 these socket options are not supported.
Responsible Changed From-To: freebsd-bugs->freebsd-net Over to maintainer(s).
Hi, Do you want to use IP_RECVDSTADDR on an AF_INET6 socket? The proper interface for an IPv6 socket is defined in RFC 3542 [ http://www.rfc-editor.org/rfc/rfc3542.txt ]. See Paragraph 6. Packet Information for what you are trying to achive. If you mean that it is possible to use IP_RECVDSTADDR on an IPv6 socket that might sound bogus. I am unsure what the correct semantics for an v4 mapped v6 address would be but that might be a reason to permit this on a limited number of sockets. If we are trying to return an IPv6 address when IP_RECVDSTADDR was set on an IPv6 socket, that sounds like a bug and should be fixed. Unfortunately your PR is not very precise about your actual problem. I guess gnn knows;-) -- Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT Software is harder than hardware so better get it right the first time.
Hi, see kern/122039 which seems to be a ``duplicate'' of this one but has a comment for discussion. /bz -- Bjoern A. Zeeb The greatest risk is not taking one.
State Changed From-To: open->closed kern/122039 is a DUP of this PR but we're closing this in favour of kern/122039 as it does contain some more information. Thank you for your report.
Responsible Changed From-To: freebsd-net->bz assign closed PR to bz as it seems to be of interest to him
State Changed From-To: closed->open have closed the wrong one - sorry
Responsible Changed From-To: bz->freebsd-bugs I shall not use bugzilla (at least until we will have a CLI).
See 122039.