Module Name:    src
Committed By:   mlelstv
Date:           Sun Nov 24 13:13:13 UTC 2013

Modified Files:
        src/usr.bin/systat: netstat.c
        src/usr.sbin/pstat: pstat.c

Log Message:
Fix fallout from circleq->tailq transition.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/systat/netstat.c
cvs rdiff -u -r1.121 -r1.122 src/usr.sbin/pstat/pstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/systat/netstat.c
diff -u src/usr.bin/systat/netstat.c:1.28 src/usr.bin/systat/netstat.c:1.29
--- src/usr.bin/systat/netstat.c:1.28	Sun Oct 22 16:43:24 2006
+++ src/usr.bin/systat/netstat.c	Sun Nov 24 13:13:12 2013
@@ -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 @@ static void
 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 @@ static void
 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;

Index: src/usr.sbin/pstat/pstat.c
diff -u src/usr.sbin/pstat/pstat.c:1.121 src/usr.sbin/pstat/pstat.c:1.122
--- src/usr.sbin/pstat/pstat.c:1.121	Sat Oct 19 17:16:38 2013
+++ src/usr.sbin/pstat/pstat.c	Sun Nov 24 13:13:12 2013
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #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 @@ kinfo_vnodes(int *avnodes)
 	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 @@ kinfo_vnodes(int *avnodes)
 			memmove(bp, &vnode, VNODESZ);
 			bp += VNODESZ;
 		}
-		if (mp == mlist.cqh_last)
-			break;
 	}
 	*avnodes = (bp - beg) / (VPTRSZ + VNODESZ);
 	return (beg);

Reply via email to