tcp_hostcache: style(9)
Reviewed by: rscheff
This commit is contained in:
parent
7c71f3bd6a
commit
4f49e3382f
@ -180,7 +180,7 @@ SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, bucketlimit,
|
|||||||
"Per-bucket hash limit for hostcache");
|
"Per-bucket hash limit for hostcache");
|
||||||
|
|
||||||
SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_VNET | CTLFLAG_RD,
|
SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_VNET | CTLFLAG_RD,
|
||||||
&VNET_NAME(tcp_hostcache.cache_count), 0,
|
&VNET_NAME(tcp_hostcache.cache_count), 0,
|
||||||
"Current number of entries in hostcache");
|
"Current number of entries in hostcache");
|
||||||
|
|
||||||
SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_VNET | CTLFLAG_RW,
|
SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_VNET | CTLFLAG_RW,
|
||||||
@ -325,7 +325,7 @@ tcp_hc_lookup(struct in_conninfo *inc, bool update)
|
|||||||
struct hc_head *hc_head;
|
struct hc_head *hc_head;
|
||||||
struct hc_metrics *hc_entry;
|
struct hc_metrics *hc_entry;
|
||||||
|
|
||||||
KASSERT(inc != NULL, ("tcp_hc_lookup with NULL in_conninfo pointer"));
|
KASSERT(inc != NULL, ("%s: NULL in_conninfo", __func__));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash the foreign ip address.
|
* Hash the foreign ip address.
|
||||||
@ -392,7 +392,7 @@ tcp_hc_insert(struct in_conninfo *inc)
|
|||||||
struct hc_head *hc_head;
|
struct hc_head *hc_head;
|
||||||
struct hc_metrics *hc_entry;
|
struct hc_metrics *hc_entry;
|
||||||
|
|
||||||
KASSERT(inc != NULL, ("tcp_hc_insert with NULL in_conninfo pointer"));
|
KASSERT(inc != NULL, ("%s: NULL in_conninfo", __func__));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash the foreign ip address.
|
* Hash the foreign ip address.
|
||||||
@ -428,14 +428,14 @@ tcp_hc_insert(struct in_conninfo *inc)
|
|||||||
*/
|
*/
|
||||||
if (hc_entry == NULL) {
|
if (hc_entry == NULL) {
|
||||||
THC_UNLOCK(&hc_head->hch_mtx);
|
THC_UNLOCK(&hc_head->hch_mtx);
|
||||||
return NULL;
|
return (NULL);
|
||||||
}
|
}
|
||||||
TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
|
TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
|
||||||
KASSERT(V_tcp_hostcache.hashbase[hash].hch_length > 0 &&
|
KASSERT(V_tcp_hostcache.hashbase[hash].hch_length > 0 &&
|
||||||
V_tcp_hostcache.hashbase[hash].hch_length <=
|
V_tcp_hostcache.hashbase[hash].hch_length <=
|
||||||
V_tcp_hostcache.bucket_limit,
|
V_tcp_hostcache.bucket_limit,
|
||||||
("tcp_hostcache: bucket length range violated at %u: %u",
|
("tcp_hostcache: bucket length range violated at %u: %u",
|
||||||
hash, V_tcp_hostcache.hashbase[hash].hch_length));
|
hash, V_tcp_hostcache.hashbase[hash].hch_length));
|
||||||
V_tcp_hostcache.hashbase[hash].hch_length--;
|
V_tcp_hostcache.hashbase[hash].hch_length--;
|
||||||
atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
|
atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
|
||||||
TCPSTAT_INC(tcps_hc_bucketoverflow);
|
TCPSTAT_INC(tcps_hc_bucketoverflow);
|
||||||
@ -449,7 +449,7 @@ tcp_hc_insert(struct in_conninfo *inc)
|
|||||||
hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT);
|
hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT);
|
||||||
if (hc_entry == NULL) {
|
if (hc_entry == NULL) {
|
||||||
THC_UNLOCK(&hc_head->hch_mtx);
|
THC_UNLOCK(&hc_head->hch_mtx);
|
||||||
return NULL;
|
return (NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,13 +471,13 @@ tcp_hc_insert(struct in_conninfo *inc)
|
|||||||
TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
|
TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
|
||||||
V_tcp_hostcache.hashbase[hash].hch_length++;
|
V_tcp_hostcache.hashbase[hash].hch_length++;
|
||||||
KASSERT(V_tcp_hostcache.hashbase[hash].hch_length <
|
KASSERT(V_tcp_hostcache.hashbase[hash].hch_length <
|
||||||
V_tcp_hostcache.bucket_limit,
|
V_tcp_hostcache.bucket_limit,
|
||||||
("tcp_hostcache: bucket length too high at %u: %u",
|
("tcp_hostcache: bucket length too high at %u: %u",
|
||||||
hash, V_tcp_hostcache.hashbase[hash].hch_length));
|
hash, V_tcp_hostcache.hashbase[hash].hch_length));
|
||||||
atomic_add_int(&V_tcp_hostcache.cache_count, 1);
|
atomic_add_int(&V_tcp_hostcache.cache_count, 1);
|
||||||
TCPSTAT_INC(tcps_hc_added);
|
TCPSTAT_INC(tcps_hc_added);
|
||||||
|
|
||||||
return hc_entry;
|
return (hc_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -534,16 +534,16 @@ tcp_hc_getmtu(struct in_conninfo *inc)
|
|||||||
uint32_t mtu;
|
uint32_t mtu;
|
||||||
|
|
||||||
if (!V_tcp_use_hostcache)
|
if (!V_tcp_use_hostcache)
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
hc_entry = tcp_hc_lookup(inc, false);
|
hc_entry = tcp_hc_lookup(inc, false);
|
||||||
if (hc_entry == NULL) {
|
if (hc_entry == NULL) {
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtu = hc_entry->rmx_mtu;
|
mtu = hc_entry->rmx_mtu;
|
||||||
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
||||||
return mtu;
|
return (mtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -589,7 +589,7 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
|
|||||||
TCPSTAT_INC(tcps_cachedrtt);
|
TCPSTAT_INC(tcps_cachedrtt);
|
||||||
}
|
}
|
||||||
if (hcml->rmx_rttvar != 0) {
|
if (hcml->rmx_rttvar != 0) {
|
||||||
if (hc_entry->rmx_rttvar == 0)
|
if (hc_entry->rmx_rttvar == 0)
|
||||||
hc_entry->rmx_rttvar = hcml->rmx_rttvar;
|
hc_entry->rmx_rttvar = hcml->rmx_rttvar;
|
||||||
else
|
else
|
||||||
hc_entry->rmx_rttvar = ((uint64_t)hc_entry->rmx_rttvar +
|
hc_entry->rmx_rttvar = ((uint64_t)hc_entry->rmx_rttvar +
|
||||||
@ -684,7 +684,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
|
|||||||
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
||||||
THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
||||||
TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
|
TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
|
||||||
rmx_q) {
|
rmx_q) {
|
||||||
sbuf_printf(&sb,
|
sbuf_printf(&sb,
|
||||||
"%-15s %5u %8u %6lums %6lums %8u %8u %8u "
|
"%-15s %5u %8u %6lums %6lums %8u %8u %8u "
|
||||||
#ifdef TCP_HC_COUNTERS
|
#ifdef TCP_HC_COUNTERS
|
||||||
@ -746,8 +746,8 @@ sysctl_tcp_hc_histo(SYSCTL_HANDLER_ARGS)
|
|||||||
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
||||||
hch_length = V_tcp_hostcache.hashbase[i].hch_length;
|
hch_length = V_tcp_hostcache.hashbase[i].hch_length;
|
||||||
KASSERT(hch_length <= V_tcp_hostcache.bucket_limit,
|
KASSERT(hch_length <= V_tcp_hostcache.bucket_limit,
|
||||||
("tcp_hostcache: bucket limit exceeded at %u: %u",
|
("tcp_hostcache: bucket limit exceeded at %u: %u",
|
||||||
i, hch_length));
|
i, hch_length));
|
||||||
histo[hch_length]++;
|
histo[hch_length]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,13 +778,14 @@ tcp_hc_purge_internal(int all)
|
|||||||
TAILQ_FOREACH_SAFE(hc_entry,
|
TAILQ_FOREACH_SAFE(hc_entry,
|
||||||
&V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q, hc_next) {
|
&V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q, hc_next) {
|
||||||
KASSERT(V_tcp_hostcache.hashbase[i].hch_length > 0 &&
|
KASSERT(V_tcp_hostcache.hashbase[i].hch_length > 0 &&
|
||||||
V_tcp_hostcache.hashbase[i].hch_length <=
|
V_tcp_hostcache.hashbase[i].hch_length <=
|
||||||
V_tcp_hostcache.bucket_limit,
|
V_tcp_hostcache.bucket_limit, ("tcp_hostcache: "
|
||||||
("tcp_hostcache: bucket length out of range at %u: %u",
|
"bucket length out of range at %u: %u",
|
||||||
i, V_tcp_hostcache.hashbase[i].hch_length));
|
i, V_tcp_hostcache.hashbase[i].hch_length));
|
||||||
if (all || hc_entry->rmx_expire <= 0) {
|
if (all || hc_entry->rmx_expire <= 0) {
|
||||||
TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket,
|
TAILQ_REMOVE(
|
||||||
hc_entry, rmx_q);
|
&V_tcp_hostcache.hashbase[i].hch_bucket,
|
||||||
|
hc_entry, rmx_q);
|
||||||
uma_zfree(V_tcp_hostcache.zone, hc_entry);
|
uma_zfree(V_tcp_hostcache.zone, hc_entry);
|
||||||
V_tcp_hostcache.hashbase[i].hch_length--;
|
V_tcp_hostcache.hashbase[i].hch_length--;
|
||||||
atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
|
atomic_subtract_int(&V_tcp_hostcache.cache_count, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user