MFC revs. 1.15, 1.16:

Add a sysctl for the purge run interval so that it can
  be tuned along with the rest of hostcache parameters.
  The new sysctl name is `net.inet.tcp.hostcache.prune'.

  Replace a constant with an already defined symbolic name for it.
This commit is contained in:
yar 2007-07-12 20:50:06 +00:00
parent 5df0ac3d5e
commit ea9934286a

View File

@ -142,6 +142,7 @@ struct tcp_hostcache {
u_int cache_count;
u_int cache_limit;
int expire;
int prune;
int purgeall;
};
static struct tcp_hostcache tcp_hostcache;
@ -170,6 +171,9 @@ SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_RD,
SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_RW,
&tcp_hostcache.expire, 0, "Expire time of TCP hostcache entries");
SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, prune, CTLFLAG_RW,
&tcp_hostcache.prune, 0, "Time between purge runs");
SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, purge, CTLFLAG_RW,
&tcp_hostcache.purgeall, 0, "Expire all entires on next purge run");
@ -209,6 +213,7 @@ tcp_hc_init(void)
tcp_hostcache.cache_limit =
tcp_hostcache.hashsize * tcp_hostcache.bucket_limit;
tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE;
tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE;
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.hashsize",
&tcp_hostcache.hashsize);
@ -218,7 +223,7 @@ tcp_hc_init(void)
&tcp_hostcache.bucket_limit);
if (!powerof2(tcp_hostcache.hashsize)) {
printf("WARNING: hostcache hash size is not a power of 2.\n");
tcp_hostcache.hashsize = 512; /* safe default */
tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */
}
tcp_hostcache.hashmask = tcp_hostcache.hashsize - 1;
@ -250,7 +255,7 @@ tcp_hc_init(void)
* Set up periodic cache cleanup.
*/
callout_init(&tcp_hc_callout, CALLOUT_MPSAFE);
callout_reset(&tcp_hc_callout, TCP_HOSTCACHE_PRUNE * hz, tcp_hc_purge, 0);
callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0);
}
/*
@ -661,9 +666,9 @@ tcp_hc_purge(void *arg)
tcp_hostcache.hashbase[i].hch_length--;
tcp_hostcache.cache_count--;
} else
hc_entry->rmx_expire -= TCP_HOSTCACHE_PRUNE;
hc_entry->rmx_expire -= tcp_hostcache.prune;
}
THC_UNLOCK(&tcp_hostcache.hashbase[i].hch_mtx);
}
callout_reset(&tcp_hc_callout, TCP_HOSTCACHE_PRUNE * hz, tcp_hc_purge, 0);
callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0);
}