Bug 118880 - [ip6] IP_RECVDSTADDR & IP_SENDSRCADDR not implemented for IPv6
Summary: [ip6] IP_RECVDSTADDR & IP_SENDSRCADDR not implemented for IPv6
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 6.3-PRERELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-20 07:40 UTC by jau
Modified: 2015-03-10 02:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jau 2007-12-20 07:40:01 UTC
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.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2007-12-20 08:10:27 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 Bjoern A. Zeeb freebsd_committer freebsd_triage 2008-03-24 13:04:09 UTC
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.
Comment 3 Bjoern A. Zeeb freebsd_committer freebsd_triage 2009-01-31 13:25:20 UTC
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.
Comment 4 Volker Werth freebsd_committer freebsd_triage 2009-01-31 14:23:06 UTC
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. 


Comment 5 Volker Werth freebsd_committer freebsd_triage 2009-01-31 14:23:06 UTC
Responsible Changed
From-To: freebsd-net->bz

assign closed PR to bz as it seems to be of interest to him
Comment 6 Volker Werth freebsd_committer freebsd_triage 2009-01-31 14:39:22 UTC
State Changed
From-To: closed->open

have closed the wrong one - sorry
Comment 7 Bjoern A. Zeeb freebsd_committer freebsd_triage 2014-05-18 06:03:39 UTC
Responsible Changed
From-To: bz->freebsd-bugs

I shall not use bugzilla (at least until we will have a CLI).
Comment 8 Mark Linimon freebsd_committer freebsd_triage 2015-03-10 02:24:14 UTC
See 122039.