Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Fix fallout from circleq->tailq transition.



details:   https://anonhg.NetBSD.org/src/rev/a76412c43cdb
branches:  trunk
changeset: 791586:a76412c43cdb
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Nov 24 13:13:12 2013 +0000

description:
Fix fallout from circleq->tailq transition.

diffstat:

 usr.bin/systat/netstat.c |  42 ++++++++++++++++++++++--------------------
 usr.sbin/pstat/pstat.c   |   9 +++------
 2 files changed, 25 insertions(+), 26 deletions(-)

diffs (127 lines):

diff -r c75e9ed88b65 -r a76412c43cdb usr.bin/systat/netstat.c
--- a/usr.bin/systat/netstat.c  Sun Nov 24 12:25:19 2013 +0000
+++ b/usr.bin/systat/netstat.c  Sun Nov 24 13:13:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netstat.c,v 1.28 2006/10/22 16:43:24 christos Exp $    */
+/*     $NetBSD: netstat.c,v 1.29 2013/11/24 13:13:12 mlelstv Exp $     */
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)netstat.c  8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: netstat.c,v 1.28 2006/10/22 16:43:24 christos Exp $");
+__RCSID("$NetBSD: netstat.c,v 1.29 2013/11/24 13:13:12 mlelstv Exp $");
 #endif /* not lint */
 
 /*
@@ -214,25 +214,26 @@
 fetchnetstat4(void *off, int istcp)
 {
        struct inpcbtable pcbtable;
-       struct inpcb *head, *prev, *next;
+       struct inpcb_hdr **pprev, *next;
        struct netinfo *p;
-       struct inpcb inpcb;
+       struct inpcb inpcb, *inpcbp;
        struct socket sockb;
        struct tcpcb tcpcb;
 
        KREAD(off, &pcbtable, sizeof pcbtable);
-       prev = head = (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue;
-       next = (struct inpcb *)pcbtable.inpt_queue.cqh_first;
-       while (next != head) {
-               KREAD(next, &inpcb, sizeof (inpcb));
-               if ((struct inpcb *)inpcb.inp_queue.cqe_prev != prev) {
+       pprev = &((struct inpcbtable *)off)->inpt_queue.tqh_first;
+       next = TAILQ_FIRST(&pcbtable.inpt_queue);
+       while (next != TAILQ_END(&pcbtable.inpt_queue)) {
+               inpcbp = (struct inpcb *)next;
+               KREAD(inpcbp, &inpcb, sizeof (inpcb));
+               if (inpcb.inp_queue.tqe_prev != pprev) {
                        for (p = netcb.ni_forw; p != nhead; p = p->ni_forw)
                                p->ni_seen = 1;
                        error("Kernel state in transition");
                        return;
                }
-               prev = next;
-               next = (struct inpcb *)inpcb.inp_queue.cqe_next;
+               pprev = &next->inph_queue.tqe_next;
+               next = inpcb.inp_queue.tqe_next;
 
                if (inpcb.inp_af != AF_INET)
                        continue;
@@ -256,25 +257,26 @@
 fetchnetstat6(void *off, int istcp)
 {
        struct inpcbtable pcbtable;
-       struct in6pcb *head6, *prev6, *next6;
+       struct inpcb_hdr **pprev, *next;
        struct netinfo *p;
        struct socket sockb;
        struct tcpcb tcpcb;
-       struct in6pcb in6pcb;
+       struct in6pcb in6pcb, *in6pcbp;
 
        KREAD(off, &pcbtable, sizeof pcbtable);
-       prev6 = head6 = (struct in6pcb *)&((struct inpcbtable *)off)->inpt_queue;
-       next6 = (struct in6pcb *)pcbtable.inpt_queue.cqh_first;
-       while (next6 != head6) {
-               KREAD(next6, &in6pcb, sizeof (in6pcb));
-               if ((struct in6pcb *)in6pcb.in6p_queue.cqe_prev != prev6) {
+       pprev = &((struct inpcbtable *)off)->inpt_queue.tqh_first;
+       next = TAILQ_FIRST(&pcbtable.inpt_queue);
+       while (next != TAILQ_END(&pcbtable.inpt_queue)) {
+               in6pcbp = (struct in6pcb *)next;
+               KREAD(in6pcbp, &in6pcb, sizeof (in6pcb));
+               if (in6pcb.in6p_queue.tqe_prev != pprev) {
                        for (p = netcb.ni_forw; p != nhead; p = p->ni_forw)
                                p->ni_seen = 1;
                        error("Kernel state in transition");
                        return;
                }
-               prev6 = next6;
-               next6 = (struct in6pcb *)in6pcb.in6p_queue.cqe_next;
+               pprev = &next->inph_queue.tqe_next;
+               next = in6pcb.in6p_queue.tqe_next;
 
                if (in6pcb.in6p_af != AF_INET6)
                        continue;
diff -r c75e9ed88b65 -r a76412c43cdb usr.sbin/pstat/pstat.c
--- a/usr.sbin/pstat/pstat.c    Sun Nov 24 12:25:19 2013 +0000
+++ b/usr.sbin/pstat/pstat.c    Sun Nov 24 13:13:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pstat.c,v 1.121 2013/10/19 17:16:38 christos Exp $     */
+/*     $NetBSD: pstat.c,v 1.122 2013/11/24 13:13:12 mlelstv Exp $      */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)pstat.c    8.16 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: pstat.c,v 1.121 2013/10/19 17:16:38 christos Exp $");
+__RCSID("$NetBSD: pstat.c,v 1.122 2013/11/24 13:13:12 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -756,8 +756,7 @@
        beg = bp;
        ep = bp + (numvnodes + 20) * (VPTRSZ + VNODESZ);
        KGET(V_MOUNTLIST, mlist);
-       for (mp = mlist.cqh_first;;
-           mp = mount.mnt_list.cqe_next) {
+       TAILQ_FOREACH(mp, &mlist, mnt_list) {
                KGET2(mp, &mount, sizeof(mount), "mount entry");
                TAILQ_FOREACH(vp, &mount.mnt_vnodelist, v_mntvnodes) {
                        KGET2(vp, &vnode, sizeof(vnode), "vnode");
@@ -769,8 +768,6 @@
                        memmove(bp, &vnode, VNODESZ);
                        bp += VNODESZ;
                }
-               if (mp == mlist.cqh_last)
-                       break;
        }
        *avnodes = (bp - beg) / (VPTRSZ + VNODESZ);
        return (beg);



Home | Main Index | Thread Index | Old Index