Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Aug 2010 16:41:16 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211433 - head/sys/netinet
Message-ID:  <201008171641.o7HGfGY4038433@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Aug 17 16:41:16 2010
New Revision: 211433
URL: http://svn.freebsd.org/changeset/base/211433

Log:
  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

Modified:
  head/sys/netinet/ip_divert.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/udp_usrreq.c

Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c	Tue Aug 17 16:27:13 2010	(r211432)
+++ head/sys/netinet/ip_divert.c	Tue Aug 17 16:41:16 2010	(r211433)
@@ -592,8 +592,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;
 	}
 

Modified: head/sys/netinet/raw_ip.c
==============================================================================
--- head/sys/netinet/raw_ip.c	Tue Aug 17 16:27:13 2010	(r211432)
+++ head/sys/netinet/raw_ip.c	Tue Aug 17 16:41:16 2010	(r211433)
@@ -993,8 +993,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);
 	}
 

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c	Tue Aug 17 16:27:13 2010	(r211432)
+++ head/sys/netinet/tcp_subr.c	Tue Aug 17 16:41:16 2010	(r211433)
@@ -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);
 	}
 

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Tue Aug 17 16:27:13 2010	(r211432)
+++ head/sys/netinet/udp_usrreq.c	Tue Aug 17 16:41:16 2010	(r211433)
@@ -707,8 +707,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);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008171641.o7HGfGY4038433>