summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_var.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/in_var.h')
-rw-r--r--sys/netinet/in_var.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index 7cef6ea..968eb2d 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -38,6 +38,7 @@
#define _NETINET_IN_VAR_H_
#include <sys/queue.h>
+#include <sys/fnv_hash.h>
/*
* Interface address, Internet version. One of these structures
@@ -55,7 +56,8 @@ struct in_ifaddr {
u_long ia_subnet; /* subnet number, including net */
u_long ia_subnetmask; /* mask of subnet part */
struct in_addr ia_netbroadcast; /* to recognize net broadcasts */
- TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */
+ LIST_ENTRY(in_ifaddr) ia_hash; /* entry in bucket of inet addresses */
+ TAILQ_ENTRY(in_ifaddr) ia_link; /* list of internet addresses */
struct sockaddr_in ia_addr; /* reserve space for interface name */
struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
#define ia_broadaddr ia_dstaddr
@@ -81,11 +83,25 @@ struct in_aliasreq {
#ifdef _KERNEL
-extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead;
extern struct ifqueue ipintrq; /* ip packet input queue */
extern struct in_addr zeroin_addr;
extern u_char inetctlerrmap[];
+/*
+ * Hash table for IP addresses.
+ */
+extern LIST_HEAD(in_ifaddrhashhead, in_ifaddr) *in_ifaddrhashtbl;
+extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead;
+extern u_long in_ifaddrhmask; /* mask for hash table */
+
+#define INADDR_NHASH_LOG2 9
+#define INADDR_NHASH (1 << INADDR_NHASH_LOG2)
+#define INADDR_HMASK (INREASS_NHASH - 1)
+#define INADDR_HASHVAL(x) fnv_32_buf((&(x)), sizeof(x), FNV1_32_INIT)
+#define INADDR_HASH(x) \
+ (&in_ifaddrhashtbl[INADDR_HASHVAL(x) & in_ifaddrhmask])
+
+
/*
* Macro for finding the interface (ifnet structure) corresponding to one
* of our IP addresses.
OpenPOWER on IntegriCloud