Author: glebius
Date: Wed Jan 27 00:48:05 2016
New Revision: 294870
URL: https://svnweb.freebsd.org/changeset/base/294870

Log:
  Grab a snap amount of TCP connections in syncache from tcpstat.

Modified:
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_syncache.h

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c Wed Jan 27 00:45:46 2016        (r294869)
+++ head/sys/netinet/tcp_subr.c Wed Jan 27 00:48:05 2016        (r294870)
@@ -1590,7 +1590,8 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
         * resource-intensive to repeat twice on every request.
         */
        if (req->oldptr == NULL) {
-               n = V_tcbinfo.ipi_count + syncache_pcbcount();
+               n = V_tcbinfo.ipi_count +
+                   TCPSTAT_FETCH(tcps_states[TCPS_SYN_RECEIVED]);
                n += imax(n / 8, 10);
                req->oldidx = 2 * (sizeof xig) + n * sizeof(struct xtcpcb);
                return (0);
@@ -1607,7 +1608,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
        n = V_tcbinfo.ipi_count;
        INP_LIST_RUNLOCK(&V_tcbinfo);
 
-       m = syncache_pcbcount();
+       m = TCPSTAT_FETCH(tcps_states[TCPS_SYN_RECEIVED]);
 
        error = sysctl_wire_old_buffer(req, 2 * (sizeof xig)
                + (n + m) * sizeof(struct xtcpcb));

Modified: head/sys/netinet/tcp_syncache.c
==============================================================================
--- head/sys/netinet/tcp_syncache.c     Wed Jan 27 00:45:46 2016        
(r294869)
+++ head/sys/netinet/tcp_syncache.c     Wed Jan 27 00:48:05 2016        
(r294870)
@@ -2100,25 +2100,6 @@ syncookie_reseed(void *arg)
 }
 
 /*
- * Returns the current number of syncache entries.  This number
- * will probably change before you get around to calling 
- * syncache_pcblist.
- */
-int
-syncache_pcbcount(void)
-{
-       struct syncache_head *sch;
-       int count, i;
-
-       for (count = 0, i = 0; i < V_tcp_syncache.hashsize; i++) {
-               /* No need to lock for a read. */
-               sch = &V_tcp_syncache.hashbase[i];
-               count += sch->sch_length;
-       }
-       return count;
-}
-
-/*
  * Exports the syncache entries to userland so that netstat can display
  * them alongside the other sockets.  This function is intended to be
  * called only from tcp_pcblist.

Modified: head/sys/netinet/tcp_syncache.h
==============================================================================
--- head/sys/netinet/tcp_syncache.h     Wed Jan 27 00:45:46 2016        
(r294869)
+++ head/sys/netinet/tcp_syncache.h     Wed Jan 27 00:48:05 2016        
(r294870)
@@ -46,7 +46,6 @@ int    syncache_add(struct in_conninfo *, 
             void *, void *);
 void    syncache_chkrst(struct in_conninfo *, struct tcphdr *);
 void    syncache_badack(struct in_conninfo *);
-int     syncache_pcbcount(void);
 int     syncache_pcblist(struct sysctl_req *req, int max_pcbs, int 
*pcbs_exported);
 
 struct syncache {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to