summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2014-10-09 02:49:33 +0000
committerae <ae@FreeBSD.org>2014-10-09 02:49:33 +0000
commit142c06446733cb14eb874687d9867f69af201fba (patch)
treeff1ad08f4c6210380494738b7ccca66c8ac06526 /sys/netinet6
parent4742b8fd12181fb4ab76f445c6bf6e95c7598e0c (diff)
downloadFreeBSD-src-142c06446733cb14eb874687d9867f69af201fba.zip
FreeBSD-src-142c06446733cb14eb874687d9867f69af201fba.tar.gz
MFC r271307:
Add the ability to set `prefer_source' flag to an IPv6 address. It affects the IPv6 source address selection algorithm (RFC 6724) and allows override the last rule ("longest matching prefix") for choosing among equivalent addresses. The address with `prefer_source' will be preferred source address.
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_src.c10
-rw-r--r--sys/netinet6/in6_var.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index b2e12be..c700969 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -451,6 +451,16 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
NEXT(9);
/*
+ * Rule 10: prefer address with `prefer_source' flag.
+ */
+ if ((ia_best->ia6_flags & IN6_IFF_PREFER_SOURCE) == 0 &&
+ (ia->ia6_flags & IN6_IFF_PREFER_SOURCE) != 0)
+ REPLACE(10);
+ if ((ia_best->ia6_flags & IN6_IFF_PREFER_SOURCE) != 0 &&
+ (ia->ia6_flags & IN6_IFF_PREFER_SOURCE) == 0)
+ NEXT(10);
+
+ /*
* Rule 14: Use longest matching prefix.
* Note: in the address selection draft, this rule is
* documented as "Rule 8". However, since it is also
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index e2f356d..e0f337f 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -503,6 +503,7 @@ struct in6_rrenumreq {
*/
#define IN6_IFF_AUTOCONF 0x40 /* autoconfigurable address. */
#define IN6_IFF_TEMPORARY 0x80 /* temporary (anonymous) address. */
+#define IN6_IFF_PREFER_SOURCE 0x0100 /* preferred address for SAS */
#define IN6_IFF_NOPFX 0x8000 /* skip kernel prefix management.
* XXX: this should be temporary.
*/
OpenPOWER on IntegriCloud