svn commit: r256595 - user/ae/inet6/sys/netinet6

Andrey V. Elsukov ae at FreeBSD.org
Wed Oct 16 08:21:44 UTC 2013


Author: ae
Date: Wed Oct 16 08:21:44 2013
New Revision: 256595
URL: http://svnweb.freebsd.org/changeset/base/256595

Log:
  Add in6_srcaddrscope() function. It is similar to in6_addrscope(), but
  returns link-local scope for IPv4-mapped addresses from 169.254/16 and
  127/8 networks.

Modified:
  user/ae/inet6/sys/netinet6/in6_src.c

Modified: user/ae/inet6/sys/netinet6/in6_src.c
==============================================================================
--- user/ae/inet6/sys/netinet6/in6_src.c	Wed Oct 16 08:19:58 2013	(r256594)
+++ user/ae/inet6/sys/netinet6/in6_src.c	Wed Oct 16 08:21:44 2013	(r256595)
@@ -143,6 +143,7 @@ static int walk_addrsel_policy(int (*)(s
 	void *);
 static int dump_addrsel_policyent(struct in6_addrpolicy *, void *);
 static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
+static int in6_srcaddrscope(const struct in6_addr *);
 
 /*
  * Return an IPv6 address, which is the most appropriate for a given
@@ -1184,3 +1185,20 @@ match_addrsel_policy(struct sockaddr_in6
 
 	return (bestpol);
 }
+
+/*
+ * This function is similar to in6_addrscope, but has some difference,
+ * specific for the source address selection algorithm (RFC 6724).
+ */
+static int
+in6_srcaddrscope(const struct in6_addr *addr)
+{
+
+	/* 169.254/16 and 127/8 have link-local scope */
+	if (IN6_IS_ADDR_V4MAPPED(addr)) {
+		if (addr->s6_addr[12] == 127 || (
+		    addr->s6_addr[12] == 169 && addr->s6_addr[13] == 254))
+			return (IPV6_ADDR_SCOPE_LINKLOCAL);
+	}
+	return (in6_addrscope(addr));
+}


More information about the svn-src-user mailing list