svn commit: r256524 - user/ae/inet6/sys/netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Tue Oct 15 11:25:13 UTC 2013
Author: ae
Date: Tue Oct 15 11:25:12 2013
New Revision: 256524
URL: http://svnweb.freebsd.org/changeset/base/256524
Log:
Add in6ifa_ifwithaddr() function.
It is similar to ifa_ifwithaddr, but uses in6_addr hash for fast lookup.
Modified:
user/ae/inet6/sys/netinet6/in6.c
user/ae/inet6/sys/netinet6/in6_var.h
Modified: user/ae/inet6/sys/netinet6/in6.c
==============================================================================
--- user/ae/inet6/sys/netinet6/in6.c Tue Oct 15 11:18:37 2013 (r256523)
+++ user/ae/inet6/sys/netinet6/in6.c Tue Oct 15 11:25:12 2013 (r256524)
@@ -1976,6 +1976,29 @@ in6ifa_ifpforlinklocal(struct ifnet *ifp
/*
+ * find the internet address corresponding to a given address.
+ * ifaddr is returned referenced.
+ */
+struct in6_ifaddr *
+in6ifa_ifwithaddr(const struct in6_addr *addr, uint32_t zoneid)
+{
+ struct in6_ifaddr *ia;
+
+ IN6_IFADDR_RLOCK();
+ LIST_FOREACH(ia, IN6ADDR_HASH(addr), ia6_hash) {
+ if (IN6_ARE_ADDR_EQUAL(IA6_IN6(ia), addr)) {
+ if (zoneid != 0 &&
+ zoneid != ia->ia_addr.sin6_scope_id)
+ continue;
+ ifa_ref(&ia->ia_ifa);
+ break;
+ }
+ }
+ IN6_IFADDR_RUNLOCK();
+ return (ia);
+}
+
+/*
* find the internet address corresponding to a given interface and address.
* ifaddr is returned referenced.
*/
Modified: user/ae/inet6/sys/netinet6/in6_var.h
==============================================================================
--- user/ae/inet6/sys/netinet6/in6_var.h Tue Oct 15 11:18:37 2013 (r256523)
+++ user/ae/inet6/sys/netinet6/in6_var.h Tue Oct 15 11:25:12 2013 (r256524)
@@ -814,6 +814,7 @@ void in6_setmaxmtu(void);
int in6_if2idlen(struct ifnet *);
struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
+struct in6_ifaddr *in6ifa_ifwithaddr(const struct in6_addr *, uint32_t);
struct in6_ifaddr *in6ifa_llaonifp(struct ifnet *);
char *ip6_sprintf(char *, const struct in6_addr *);
int in6_addr2zoneid(struct ifnet *, struct in6_addr *, u_int32_t *);
More information about the svn-src-user
mailing list