Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159224803
D29471.id86439.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D29471.id86439.diff
View Options
Index: sys/netinet/tcp_hostcache.c
===================================================================
--- sys/netinet/tcp_hostcache.c
+++ sys/netinet/tcp_hostcache.c
@@ -626,9 +626,8 @@
static int
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
{
- const int linesize = 128;
struct sbuf sb;
- int i, error;
+ int i, error = 0;
struct hc_metrics *hc_entry;
char ip4buf[INET_ADDRSTRLEN];
#ifdef INET6
@@ -638,48 +637,48 @@
if (jailed_without_vnet(curthread->td_ucred) != 0)
return (EPERM);
- sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1),
- SBUF_INCLUDENUL);
+ error = sysctl_wire_old_buffer(req, 0);
+ if (error == 0) {
+ sbuf_new_for_sysctl(&sb, NULL, 512, req);
- sbuf_printf(&sb,
- "\nIP address MTU SSTRESH RTT RTTVAR "
- " CWND SENDPIPE RECVPIPE HITS UPD EXP\n");
+ sbuf_printf(&sb,
+ "\nIP address MTU SSTRESH RTT RTTVAR "
+ " CWND SENDPIPE RECVPIPE HITS UPD EXP\n");
#define msec(u) (((u) + 500) / 1000)
- for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
- THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
- TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
- rmx_q) {
- sbuf_printf(&sb,
- "%-15s %5u %8u %6lums %6lums %8u %8u %8u %4lu "
- "%4lu %4i\n",
- hc_entry->ip4.s_addr ?
- inet_ntoa_r(hc_entry->ip4, ip4buf) :
+ for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
+ THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
+ TAILQ_FOREACH(hc_entry,
+ &V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q) {
+ sbuf_printf(&sb,
+ "%-15s %5u %8u %6lums %6lums %8u %8u "
+ "%8u %4lu %4lu %4i\n",
+ hc_entry->ip4.s_addr ?
+ inet_ntoa_r(hc_entry->ip4, ip4buf) :
#ifdef INET6
- ip6_sprintf(ip6buf, &hc_entry->ip6),
+ ip6_sprintf(ip6buf, &hc_entry->ip6),
#else
- "IPv6?",
+ "IPv6?",
#endif
- hc_entry->rmx_mtu,
- hc_entry->rmx_ssthresh,
- msec((u_long)hc_entry->rmx_rtt *
- (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
- msec((u_long)hc_entry->rmx_rttvar *
- (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))),
- hc_entry->rmx_cwnd,
- hc_entry->rmx_sendpipe,
- hc_entry->rmx_recvpipe,
- hc_entry->rmx_hits,
- hc_entry->rmx_updates,
- hc_entry->rmx_expire);
+ hc_entry->rmx_mtu,
+ hc_entry->rmx_ssthresh,
+ msec((u_long)hc_entry->rmx_rtt *
+ (RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
+ msec((u_long)hc_entry->rmx_rttvar *
+ (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))),
+ hc_entry->rmx_cwnd,
+ hc_entry->rmx_sendpipe,
+ hc_entry->rmx_recvpipe,
+ hc_entry->rmx_hits,
+ hc_entry->rmx_updates,
+ hc_entry->rmx_expire);
+ }
+ THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
}
- THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
- }
#undef msec
- error = sbuf_finish(&sb);
- if (error == 0)
- error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb));
- sbuf_delete(&sb);
+ error = sbuf_finish(&sb);
+ sbuf_delete(&sb);
+ }
return(error);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jun 12, 1:26 PM (6 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33908340
Default Alt Text
D29471.id86439.diff (2 KB)
Attached To
Mode
D29471: Avoid /sbin/sysctl net.inet.tcp.hostcache.list from stalling when under memory pressure
Attached
Detach File
Event Timeline
Log In to Comment