aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2010-08-17 16:41:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2010-08-17 16:41:16 +0000
commitc007b96a78972be20a2f1970e4a6f283b0e434b7 (patch)
treeac22d40e259520b3863696d63c529cccfd9def23 /sys/netinet/tcp_subr.c
parenta122fea4ff5aef851b20383d0d5776c38e2422ff (diff)
downloadsrc-c007b96a78972be20a2f1970e4a6f283b0e434b7.tar.gz
src-c007b96a78972be20a2f1970e4a6f283b0e434b7.zip
Ensure a minimum "slop" of 10 extra pcb structures when providing a
memory size estimate to userland for pcb list sysctls. The previous behavior of a "slop" of n/8 does not work well for small values of n (e.g. no slop at all if you have less than 8 open UDP connections). Reviewed by: bz MFC after: 1 week
Notes
Notes: svn path=/head/; revision=211433
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index da478b3116ba..bfa3e663f005 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1022,8 +1022,9 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
if (req->oldptr == NULL) {
m = syncache_pcbcount();
n = V_tcbinfo.ipi_count;
- req->oldidx = 2 * (sizeof xig)
- + ((m + n) + n/8) * sizeof(struct xtcpcb);
+ n += imax(n / 8, 10);
+ req->oldidx = 2 * (sizeof xig) +
+ (m + n) * sizeof(struct xtcpcb);
return (0);
}