network - Fix netstat output missing entries
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 2 Nov 2010 05:08:35 +0000 (22:08 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 2 Nov 2010 05:12:04 +0000 (22:12 -0700)
* netstat was missing entries due to the kernel pcb listing sysctl
  code doing a bogus generation count test which did not take into
  account pcb's which move between cpus due to e.g. a bind() operation.

Reported-by: Thomas Nikolajsen <thomas.nikolajsen@mail.dk>
sys/netinet/in_pcb.c
sys/netinet/tcp_subr.c

index 819dcef..e85e2b2 100644 (file)
@@ -1335,7 +1335,6 @@ in_pcblist_global(SYSCTL_HANDLER_ARGS)
        struct inpcb *inp, *marker;
        struct xinpcb xi;
        int error, i, n;
-       inp_gen_t gencnt;
 
        /*
         * The process of preparing the TCB list is too time-consuming and
@@ -1354,7 +1353,6 @@ in_pcblist_global(SYSCTL_HANDLER_ARGS)
         * OK, now we're committed to doing something.  Re-fetch ipi_count
         * after obtaining the generation count.
         */
-       gencnt = pcbinfo->ipi_gencnt;
        n = pcbinfo->ipi_count;
 
        marker = kmalloc(sizeof(struct inpcb), M_TEMP, M_WAITOK|M_ZERO);
@@ -1370,8 +1368,6 @@ in_pcblist_global(SYSCTL_HANDLER_ARGS)
 
                if (inp->inp_flags & INP_PLACEMARKER)
                        continue;
-               if (inp->inp_gencnt > gencnt)
-                       continue;
                if (prison_xinpcb(req->td, inp))
                        continue;
                bzero(&xi, sizeof xi);
index 686a8de..de97ffe 100644 (file)
@@ -1134,7 +1134,6 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
        int error, i, n;
        struct inpcb *marker;
        struct inpcb *inp;
-       inp_gen_t gencnt;
        globaldata_t gd;
        int origcpu, ccpu;
 
@@ -1180,7 +1179,6 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
                rgd = globaldata_find(cpu_id);
                lwkt_setcpu_self(rgd);
 
-               gencnt = tcbinfo[cpu_id].ipi_gencnt;
                n = tcbinfo[cpu_id].ipi_count;
 
                LIST_INSERT_HEAD(&tcbinfo[cpu_id].pcblisthead, marker, inp_list);
@@ -1195,8 +1193,6 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
 
                        if (inp->inp_flags & INP_PLACEMARKER)
                                continue;
-                       if (inp->inp_gencnt > gencnt)
-                               continue;
                        if (prison_xinpcb(req->td, inp))
                                continue;