Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_hostcache.c
Show First 20 Lines • Show All 620 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Sysctl function: prints the list and values of all hostcache entries in | * Sysctl function: prints the list and values of all hostcache entries in | ||||
* unsorted order. | * unsorted order. | ||||
*/ | */ | ||||
static int | static int | ||||
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) | sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
const int linesize = 128; | |||||
struct sbuf sb; | struct sbuf sb; | ||||
int i, error; | int i, error = 0; | ||||
hselasky: Setting error to 0 is superfluous from what I can see. | |||||
struct hc_metrics *hc_entry; | struct hc_metrics *hc_entry; | ||||
char ip4buf[INET_ADDRSTRLEN]; | char ip4buf[INET_ADDRSTRLEN]; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
char ip6buf[INET6_ADDRSTRLEN]; | char ip6buf[INET6_ADDRSTRLEN]; | ||||
#endif | #endif | ||||
if (jailed_without_vnet(curthread->td_ucred) != 0) | if (jailed_without_vnet(curthread->td_ucred) != 0) | ||||
return (EPERM); | return (EPERM); | ||||
sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), | error = sysctl_wire_old_buffer(req, 0); | ||||
SBUF_INCLUDENUL); | if (error == 0) { | ||||
sbuf_new_for_sysctl(&sb, NULL, 512, req); | |||||
sbuf_printf(&sb, | sbuf_printf(&sb, | ||||
"\nIP address MTU SSTRESH RTT RTTVAR " | "\nIP address MTU SSTRESH RTT RTTVAR " | ||||
" CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); | " CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); | ||||
#define msec(u) (((u) + 500) / 1000) | #define msec(u) (((u) + 500) / 1000) | ||||
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, | ||||
rmx_q) { | &V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q) { | ||||
sbuf_printf(&sb, | sbuf_printf(&sb, | ||||
"%-15s %5u %8u %6lums %6lums %8u %8u %8u %4lu " | "%-15s %5u %8u %6lums %6lums %8u %8u " | ||||
"%4lu %4i\n", | "%8u %4lu %4lu %4i\n", | ||||
hc_entry->ip4.s_addr ? | hc_entry->ip4.s_addr ? | ||||
inet_ntoa_r(hc_entry->ip4, ip4buf) : | inet_ntoa_r(hc_entry->ip4, ip4buf) : | ||||
#ifdef INET6 | #ifdef INET6 | ||||
ip6_sprintf(ip6buf, &hc_entry->ip6), | ip6_sprintf(ip6buf, &hc_entry->ip6), | ||||
#else | #else | ||||
"IPv6?", | "IPv6?", | ||||
#endif | #endif | ||||
hc_entry->rmx_mtu, | hc_entry->rmx_mtu, | ||||
hc_entry->rmx_ssthresh, | hc_entry->rmx_ssthresh, | ||||
msec((u_long)hc_entry->rmx_rtt * | msec((u_long)hc_entry->rmx_rtt * | ||||
(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), | (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))), | ||||
msec((u_long)hc_entry->rmx_rttvar * | msec((u_long)hc_entry->rmx_rttvar * | ||||
(RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))), | (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))), | ||||
hc_entry->rmx_cwnd, | hc_entry->rmx_cwnd, | ||||
hc_entry->rmx_sendpipe, | hc_entry->rmx_sendpipe, | ||||
hc_entry->rmx_recvpipe, | hc_entry->rmx_recvpipe, | ||||
hc_entry->rmx_hits, | hc_entry->rmx_hits, | ||||
hc_entry->rmx_updates, | hc_entry->rmx_updates, | ||||
hc_entry->rmx_expire); | hc_entry->rmx_expire); | ||||
} | } | ||||
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); | ||||
} | } | ||||
#undef msec | #undef msec | ||||
error = sbuf_finish(&sb); | error = sbuf_finish(&sb); | ||||
if (error == 0) | |||||
error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); | |||||
sbuf_delete(&sb); | sbuf_delete(&sb); | ||||
} | |||||
return(error); | return(error); | ||||
} | } | ||||
/* | /* | ||||
* Caller has to make sure the curvnet is set properly. | * Caller has to make sure the curvnet is set properly. | ||||
*/ | */ | ||||
static void | static void | ||||
tcp_hc_purge_internal(int all) | tcp_hc_purge_internal(int all) | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
Setting error to 0 is superfluous from what I can see.