+ lck_mtx_lock(nfsrv_reqcache_mutex);
+ /* init nfs server request cache hash table */
+ nfsrv_reqcache_hashtbl = hashinit(nfsrv_reqcache_size, M_NFSD, &nfsrv_reqcache_hash);
+ TAILQ_INIT(&nfsrv_reqcache_lruhead);
+ lck_mtx_unlock(nfsrv_reqcache_mutex);
+}
+
+/*
+ * This function compares two net addresses by family and returns TRUE
+ * if they are the same host.
+ * If there is any doubt, return FALSE.
+ * The AF_INET family is handled as a special case so that address mbufs
+ * don't need to be saved to store "struct in_addr", which is only 4 bytes.
+ * Ditto for AF_INET6 which is only 16 bytes.
+ */
+static int
+netaddr_match(
+ int family,
+ union nethostaddr *haddr,
+ mbuf_t nam)
+{
+ struct sockaddr_in *inetaddr;
+ struct sockaddr_in6 *inet6addr;
+
+ switch (family) {
+ case AF_INET:
+ inetaddr = mbuf_data(nam);
+ if ((inetaddr->sin_family == AF_INET) &&
+ (inetaddr->sin_addr.s_addr == haddr->had_inetaddr)) {
+ return 1;
+ }
+ break;
+ case AF_INET6:
+ inet6addr = mbuf_data(nam);
+ if ((inet6addr->sin6_family == AF_INET6) &&
+ !bcmp(&inet6addr->sin6_addr, &haddr->had_inet6addr, sizeof(inet6addr->sin6_addr))) {
+ return 1;
+ }
+ break;
+ }
+ return 0;