On Wed, Feb 20, 2013 at 12:36:13AM -0600, Todd T. Fries wrote: > The source address selection mechanism in IPv4 is to my understanding: > > the first address on the interface associated with the route > to the remote host > > The source address selection mechanism in IPv6 is to my understanding: > > for each of the global addresses on a system, turn it into an integer > and subtract it from the destination address. The difference closest > to zero decides what address will be selected because it is 'closest'. > > Personally I'd be happy if IPv6 mimicked IPv4 in this regard. Other OS's > permit configurable address selection criteria in the kernel, but I'll be > the first to suggest this is not the OpenBSD way. The default should be > good enough and .. this is not good enough for me in every scenario I've > encountered it.
I am running with this diff for a while now. It gives the outgoing interface a higher priority when selecting an IPv6 source addresse. More and more RFCs on that topic get published, making things more complicated. I am not convinced that this diff is good solution in general. bluhm Index: netinet6/in6.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.c,v retrieving revision 1.101 diff -u -p -r1.101 in6.c --- netinet6/in6.c 30 Nov 2012 13:48:12 -0000 1.101 +++ netinet6/in6.c 3 Feb 2013 12:09:31 -0000 @@ -2263,6 +2263,12 @@ in6_ifawithscope(struct ifnet *oifp, str IN6_IFF_DEPRECATED) == 0) goto replace; + /* RFC 3484 5. Rule 5: Prefer outgoing interface */ + if (ifa_best->ia_ifp == oifp && ifp != oifp) + continue; + if (ifa_best->ia_ifp != oifp && ifp == oifp) + goto replace; + /* * At this point, we have two cases: * 1. we are looking at a non-deprecated address,