View | Details | Raw Unified | Return to bug 172675 | Differences between
and this patch

Collapse All | Expand All

(-)tcp_hostcache.c (-13 / +11 lines)
Lines 73-78 __FBSDID("$FreeBSD$"); Link Here
73
#include <sys/lock.h>
73
#include <sys/lock.h>
74
#include <sys/mutex.h>
74
#include <sys/mutex.h>
75
#include <sys/malloc.h>
75
#include <sys/malloc.h>
76
#include <sys/sbuf.h>
76
#include <sys/socket.h>
77
#include <sys/socket.h>
77
#include <sys/socketvar.h>
78
#include <sys/socketvar.h>
78
#include <sys/sysctl.h>
79
#include <sys/sysctl.h>
Lines 595-617 tcp_hc_update(struct in_conninfo *inc, struct hc_m Link Here
595
static int
596
static int
596
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
597
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
597
{
598
{
598
	int bufsize;
599
	int linesize = 128;
599
	int linesize = 128;
600
	char *p, *buf;
600
	struct sbuf sb;
601
	int len, i, error;
601
	int i, error;
602
	struct hc_metrics *hc_entry;
602
	struct hc_metrics *hc_entry;
603
#ifdef INET6
603
#ifdef INET6
604
	char ip6buf[INET6_ADDRSTRLEN];
604
	char ip6buf[INET6_ADDRSTRLEN];
605
#endif
605
#endif
606
606
607
	bufsize = linesize * (V_tcp_hostcache.cache_count + 1);
607
	sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1),
608
	    SBUF_FIXEDLEN);
608
609
609
	p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO);
610
	sbuf_printf(&sb,
610
611
	        "\nIP address        MTU  SSTRESH      RTT   RTTVAR BANDWIDTH "
611
	len = snprintf(p, linesize,
612
		"\nIP address        MTU  SSTRESH      RTT   RTTVAR BANDWIDTH "
613
		"    CWND SENDPIPE RECVPIPE HITS  UPD  EXP\n");
612
		"    CWND SENDPIPE RECVPIPE HITS  UPD  EXP\n");
614
	p += len;
615
613
616
#define msec(u) (((u) + 500) / 1000)
614
#define msec(u) (((u) + 500) / 1000)
617
	for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
615
	for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
Lines 618-624 sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) Link Here
618
		THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
616
		THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
619
		TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
617
		TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
620
			      rmx_q) {
618
			      rmx_q) {
621
			len = snprintf(p, linesize,
619
			sbuf_printf(&sb,
622
			    "%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu "
620
			    "%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu "
623
			    "%4lu %4lu %4i\n",
621
			    "%4lu %4lu %4i\n",
624
			    hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) :
622
			    hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) :
Lines 640-652 sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) Link Here
640
			    hc_entry->rmx_hits,
638
			    hc_entry->rmx_hits,
641
			    hc_entry->rmx_updates,
639
			    hc_entry->rmx_updates,
642
			    hc_entry->rmx_expire);
640
			    hc_entry->rmx_expire);
643
			p += len;
644
		}
641
		}
645
		THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
642
		THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
646
	}
643
	}
647
#undef msec
644
#undef msec
648
	error = SYSCTL_OUT(req, buf, p - buf);
645
	sbuf_finish(&sb);
649
	free(buf, M_TEMP);
646
	error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb));
647
	sbuf_delete(&sb);
650
	return(error);
648
	return(error);
651
}
649
}
652
650

Return to bug 172675