svn commit: r271427 - head/sys/netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Thu Sep 11 13:18:42 UTC 2014
Author: ae
Date: Thu Sep 11 13:18:41 2014
New Revision: 271427
URL: http://svnweb.freebsd.org/changeset/base/271427
Log:
Add const qualifier to in6_addrhash() function.
Add in6ifa_ifwithaddr() function. It is similar to ifa_ifwithaddr,
but does fast lookup in the hash of inet6 addresses.
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Modified:
head/sys/netinet6/in6.c
head/sys/netinet6/in6_var.h
Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c Thu Sep 11 12:54:17 2014 (r271426)
+++ head/sys/netinet6/in6.c Thu Sep 11 13:18:41 2014 (r271427)
@@ -1715,6 +1715,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: head/sys/netinet6/in6_var.h
==============================================================================
--- head/sys/netinet6/in6_var.h Thu Sep 11 12:54:17 2014 (r271426)
+++ head/sys/netinet6/in6_var.h Thu Sep 11 13:18:41 2014 (r271427)
@@ -526,7 +526,7 @@ VNET_DECLARE(u_long, in6_ifaddrhmask);
(&V_in6_ifaddrhashtbl[IN6ADDR_HASHVAL(x) & V_in6_ifaddrhmask])
static __inline uint32_t
-in6_addrhash(struct in6_addr *in6)
+in6_addrhash(const struct in6_addr *in6)
{
uint32_t x;
@@ -812,6 +812,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-all
mailing list