Lines Matching refs:V_tcp_hostcache

117 #define	V_tcp_hostcache		VNET(tcp_hostcache)  macro
187 (jenkins_hash32((uint32_t *)(ip), 1, V_tcp_hostcache.hashsalt) & \
188 V_tcp_hostcache.hashmask)
192 V_tcp_hostcache.hashsalt) & \
193 V_tcp_hostcache.hashmask)
207 atomic_store_int(&V_tcp_hostcache.cache_count, 0); in tcp_hc_init()
208 V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; in tcp_hc_init()
209 V_tcp_hostcache.bucket_limit = TCP_HOSTCACHE_BUCKETLIMIT; in tcp_hc_init()
210 V_tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE; in tcp_hc_init()
211 V_tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE; in tcp_hc_init()
212 V_tcp_hostcache.hashsalt = arc4random(); in tcp_hc_init()
215 &V_tcp_hostcache.hashsize); in tcp_hc_init()
216 if (!powerof2(V_tcp_hostcache.hashsize)) { in tcp_hc_init()
218 V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */ in tcp_hc_init()
220 V_tcp_hostcache.hashmask = V_tcp_hostcache.hashsize - 1; in tcp_hc_init()
223 &V_tcp_hostcache.bucket_limit); in tcp_hc_init()
225 cache_limit = V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit; in tcp_hc_init()
226 V_tcp_hostcache.cache_limit = cache_limit; in tcp_hc_init()
228 &V_tcp_hostcache.cache_limit); in tcp_hc_init()
229 if (V_tcp_hostcache.cache_limit > cache_limit) in tcp_hc_init()
230 V_tcp_hostcache.cache_limit = cache_limit; in tcp_hc_init()
235 V_tcp_hostcache.hashbase = (struct hc_head *) in tcp_hc_init()
236 malloc(V_tcp_hostcache.hashsize * sizeof(struct hc_head), in tcp_hc_init()
242 for (i = 0; i < V_tcp_hostcache.hashsize; i++) { in tcp_hc_init()
243 TAILQ_INIT(&V_tcp_hostcache.hashbase[i].hch_bucket); in tcp_hc_init()
244 V_tcp_hostcache.hashbase[i].hch_length = 0; in tcp_hc_init()
245 mtx_init(&V_tcp_hostcache.hashbase[i].hch_mtx, "tcp_hc_entry", in tcp_hc_init()
252 V_tcp_hostcache.zone = in tcp_hc_init()
255 uma_zone_set_max(V_tcp_hostcache.zone, V_tcp_hostcache.cache_limit); in tcp_hc_init()
261 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz, in tcp_hc_init()
277 uma_zdestroy(V_tcp_hostcache.zone); in tcp_hc_destroy()
279 for (i = 0; i < V_tcp_hostcache.hashsize; i++) in tcp_hc_destroy()
280 mtx_destroy(&V_tcp_hostcache.hashbase[i].hch_mtx); in tcp_hc_destroy()
281 free(V_tcp_hostcache.hashbase, M_HOSTCACHE); in tcp_hc_destroy()
311 hc_head = &V_tcp_hostcache.hashbase[hash]; in tcp_hc_lookup()
370 hc_head = &V_tcp_hostcache.hashbase[hash]; in tcp_hc_insert()
382 if (hc_head->hch_length >= V_tcp_hostcache.bucket_limit || in tcp_hc_insert()
383 atomic_load_int(&V_tcp_hostcache.cache_count) >= V_tcp_hostcache.cache_limit) { in tcp_hc_insert()
399 KASSERT(V_tcp_hostcache.hashbase[hash].hch_length > 0 && in tcp_hc_insert()
400 V_tcp_hostcache.hashbase[hash].hch_length <= in tcp_hc_insert()
401 V_tcp_hostcache.bucket_limit, in tcp_hc_insert()
403 hash, V_tcp_hostcache.hashbase[hash].hch_length)); in tcp_hc_insert()
404 V_tcp_hostcache.hashbase[hash].hch_length--; in tcp_hc_insert()
405 atomic_subtract_int(&V_tcp_hostcache.cache_count, 1); in tcp_hc_insert()
408 uma_zfree(V_tcp_hostcache.zone, hc_entry); in tcp_hc_insert()
414 hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT); in tcp_hc_insert()
431 hc_entry->rmx_expire = V_tcp_hostcache.expire; in tcp_hc_insert()
437 V_tcp_hostcache.hashbase[hash].hch_length++; in tcp_hc_insert()
438 KASSERT(V_tcp_hostcache.hashbase[hash].hch_length < in tcp_hc_insert()
439 V_tcp_hostcache.bucket_limit, in tcp_hc_insert()
441 hash, V_tcp_hostcache.hashbase[hash].hch_length)); in tcp_hc_insert()
442 atomic_add_int(&V_tcp_hostcache.cache_count, 1); in tcp_hc_insert()
476 hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ in tcp_hc_get()
511 hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ in tcp_hc_getmtu()
544 hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ in tcp_hc_updatemtu()
579 hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */ in tcp_hc_update()
658 len = (atomic_load_int(&V_tcp_hostcache.cache_count) + 1) * in sysctl_tcp_hc_list()
669 sbuf_new_for_sysctl(&sb, NULL, V_tcp_hostcache.bucket_limit * in sysctl_tcp_hc_list()
678 for (i = 0; i < V_tcp_hostcache.hashsize; i++) { in sysctl_tcp_hc_list()
679 THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); in sysctl_tcp_hc_list()
680 TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket, in sysctl_tcp_hc_list()
705 THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); in sysctl_tcp_hc_list()
730 histo = (int *)malloc(sizeof(int) * (V_tcp_hostcache.bucket_limit + 1), in sysctl_tcp_hc_histo()
735 for (i = 0; i < V_tcp_hostcache.hashsize; i++) { in sysctl_tcp_hc_histo()
736 hch_length = V_tcp_hostcache.hashbase[i].hch_length; in sysctl_tcp_hc_histo()
737 KASSERT(hch_length <= V_tcp_hostcache.bucket_limit, in sysctl_tcp_hc_histo()
747 for (i = 0; i <= V_tcp_hostcache.bucket_limit; i++) { in sysctl_tcp_hc_histo()
765 for (i = 0; i < V_tcp_hostcache.hashsize; i++) { in tcp_hc_purge_internal()
766 THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); in tcp_hc_purge_internal()
768 &V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q, hc_next) { in tcp_hc_purge_internal()
769 KASSERT(V_tcp_hostcache.hashbase[i].hch_length > 0 && in tcp_hc_purge_internal()
770 V_tcp_hostcache.hashbase[i].hch_length <= in tcp_hc_purge_internal()
771 V_tcp_hostcache.bucket_limit, in tcp_hc_purge_internal()
773 i, V_tcp_hostcache.hashbase[i].hch_length)); in tcp_hc_purge_internal()
775 TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket, in tcp_hc_purge_internal()
777 uma_zfree(V_tcp_hostcache.zone, hc_entry); in tcp_hc_purge_internal()
778 V_tcp_hostcache.hashbase[i].hch_length--; in tcp_hc_purge_internal()
779 atomic_subtract_int(&V_tcp_hostcache.cache_count, 1); in tcp_hc_purge_internal()
781 hc_entry->rmx_expire -= V_tcp_hostcache.prune; in tcp_hc_purge_internal()
783 THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); in tcp_hc_purge_internal()
797 if (V_tcp_hostcache.purgeall) { in tcp_hc_purge()
798 if (V_tcp_hostcache.purgeall == 2) in tcp_hc_purge()
799 V_tcp_hostcache.hashsalt = arc4random(); in tcp_hc_purge()
801 V_tcp_hostcache.purgeall = 0; in tcp_hc_purge()
806 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz, in tcp_hc_purge()
825 V_tcp_hostcache.hashsalt = arc4random(); in sysctl_tcp_hc_purgenow()
828 callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz, in sysctl_tcp_hc_purgenow()