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);
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to