Index: sys/netinet/tcp_hostcache.c =================================================================== --- sys/netinet/tcp_hostcache.c +++ sys/netinet/tcp_hostcache.c @@ -628,7 +628,7 @@ { const int linesize = 128; struct sbuf sb; - int i, error, len; + int i, error, len, do_drain; struct hc_metrics *hc_entry; char ip4buf[INET_ADDRSTRLEN]; #ifdef INET6 @@ -649,15 +649,19 @@ return(error); } - /* Use a buffer for 16 lines */ - sbuf_new_for_sysctl(&sb, NULL, 16 * linesize, req); + /* Use a buffer sized for one full bucket */ + sbuf_new_for_sysctl(&sb, NULL, V_tcp_hostcache.bucket_limit * linesize, req); sbuf_printf(&sb, "\nIP address MTU SSTRESH RTT RTTVAR " " CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); + do_drain = 1; #define msec(u) (((u) + 500) / 1000) for (i = 0; i < V_tcp_hostcache.hashsize; i++) { + if (do_drain) + sbuf_drain(&sb); + do_drain = 0; THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q) { @@ -683,6 +687,7 @@ hc_entry->rmx_hits, hc_entry->rmx_updates, hc_entry->rmx_expire); + do_drain = 1; } THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); }