diff options
author | John Baldwin <jhb@FreeBSD.org> | 2010-08-27 18:50:12 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2010-08-27 18:50:12 +0000 |
commit | f749e399cbec9d9f9dc907f055794ef8c85ca0a8 (patch) | |
tree | 120d5ff55b0d7accc6e498546a71381d7a2f6dd2 | |
parent | 2b9d9e2d4b0f969796c995bbbc424bc6049b5ce1 (diff) | |
download | src-f749e399cbec9d9f9dc907f055794ef8c85ca0a8.tar.gz src-f749e399cbec9d9f9dc907f055794ef8c85ca0a8.zip |
MFC 211433:
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).
Notes
Notes:
svn path=/stable/8/; revision=211889
-rw-r--r-- | sys/netinet/ip_divert.c | 4 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 4 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 5 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 4 |
4 files changed, 9 insertions, 8 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 86f2305c3851..b1c440301237 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -614,8 +614,8 @@ div_pcblist(SYSCTL_HANDLER_ARGS) */ if (req->oldptr == 0) { n = V_divcbinfo.ipi_count; - req->oldidx = 2 * (sizeof xig) - + (n + n/8) * sizeof(struct xinpcb); + n += imax(n / 8, 10); + req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xinpcb); return 0; } diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 52e923d79bac..69ba63c1f046 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1007,8 +1007,8 @@ rip_pcblist(SYSCTL_HANDLER_ARGS) */ if (req->oldptr == 0) { n = V_ripcbinfo.ipi_count; - req->oldidx = 2 * (sizeof xig) - + (n + n/8) * sizeof(struct xinpcb); + n += imax(n / 8, 10); + req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xinpcb); return (0); } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 16743c063bd7..ecc4086f41ce 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1018,8 +1018,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); } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index c89a3b4122bb..ad8a51b86a88 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -727,8 +727,8 @@ udp_pcblist(SYSCTL_HANDLER_ARGS) */ if (req->oldptr == 0) { n = V_udbinfo.ipi_count; - req->oldidx = 2 * (sizeof xig) - + (n + n/8) * sizeof(struct xinpcb); + n += imax(n / 8, 10); + req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xinpcb); return (0); } |