summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/scope6.c
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2015-12-08 10:50:03 +0000
committermelifaro <melifaro@FreeBSD.org>2015-12-08 10:50:03 +0000
commitca13483a3ceb41301eee9d9d194676056a9b304a (patch)
tree6ca921174b94c73570e52b7776a5a84068f7a02f /sys/netinet6/scope6.c
parent857f62b52e4aba63ee7b8c0eeaba0da2e8ae21e5 (diff)
downloadFreeBSD-src-ca13483a3ceb41301eee9d9d194676056a9b304a.zip
FreeBSD-src-ca13483a3ceb41301eee9d9d194676056a9b304a.tar.gz
Merge helper fib* functions used for basic lookups.
Vast majority of rtalloc(9) users require only basic info from route table (e.g. "does the rtentry interface match with the interface I have?". "what is the MTU?", "Give me the IPv4 source address to use", etc..). Instead of hand-rolling lookups, checking if rtentry is up, valid, dealing with IPv6 mtu, finding "address" ifp (almost never done right), provide easy-to-use API hiding all the complexity and returning the needed info into small on-stack structure. This change also helps hiding route subsystem internals (locking, direct rtentry accesses). Additionaly, using this API improves lookup performance since rtentry is not locked. (This is safe, since all the rtentry changes happens under both radix WLOCK and rtentry WLOCK). Sponsored by: Yandex LLC
Diffstat (limited to 'sys/netinet6/scope6.c')
-rw-r--r--sys/netinet6/scope6.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c
index 0e4d303..1a9d038 100644
--- a/sys/netinet6/scope6.c
+++ b/sys/netinet6/scope6.c
@@ -487,6 +487,22 @@ in6_getscopezone(const struct ifnet *ifp, int scope)
}
/*
+ * Extracts scope from adddress @dst, stores cleared address
+ * inside @dst and zone inside @scopeid
+ */
+void
+in6_splitscope(const struct in6_addr *src, struct in6_addr *dst,
+ uint32_t *scopeid)
+{
+ uint32_t zoneid;
+
+ *dst = *src;
+ zoneid = ntohs(in6_getscope(dst));
+ in6_clearscope(dst);
+ *scopeid = zoneid;
+}
+
+/*
* This function is for checking sockaddr_in6 structure passed
* from the application level (usually).
*
OpenPOWER on IntegriCloud