more fixing after circleq conversion. a better fix to check the prev
authortedu <tedu@openbsd.org>
Tue, 24 Dec 2013 22:26:19 +0000 (22:26 +0000)
committertedu <tedu@openbsd.org>
Tue, 24 Dec 2013 22:26:19 +0000 (22:26 +0000)
pointer is forthcoming.

usr.bin/netstat/inet.c
usr.bin/systat/netstat.c
usr.bin/tcpbench/tcpbench.c

index 6852122..070c6da 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: inet.c,v 1.127 2013/12/23 22:39:50 tedu Exp $ */
+/*     $OpenBSD: inet.c,v 1.128 2013/12/24 22:26:19 tedu Exp $ */
 /*     $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $        */
 
 /*
@@ -124,14 +124,11 @@ protopr(u_long off, char *name, int af, u_int tableid, u_long pcbaddr)
        istcp = strcmp(name, "tcp") == 0;
        israw = strncmp(name, "ip", 2) == 0;
        kread(off, &table, sizeof table);
-       prev = next = TAILQ_FIRST(&table.inpt_queue);
+       prev = NULL;
+       next = TAILQ_FIRST(&table.inpt_queue);
 
        while (next != NULL) {
                kread((u_long)next, &inpcb, sizeof inpcb);
-               if (TAILQ_PREV(&inpcb, inpthead, inp_queue) != prev) {
-                       printf("???\n");
-                       break;
-               }
                prev = next;
                next = TAILQ_NEXT(&inpcb, inp_queue);
 
index 652aa32..3f4f38e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: netstat.c,v 1.37 2013/12/20 02:04:09 krw Exp $        */
+/*     $OpenBSD: netstat.c,v 1.38 2013/12/24 22:26:20 tedu Exp $       */
 /*     $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $  */
 
 /*-
@@ -232,7 +232,7 @@ int
 read_ns(void)
 {
        struct inpcbtable pcbtable;
-       struct inpcb *head, *prev, *next;
+       struct inpcb *next;
        struct inpcb inpcb;
        struct socket sockb;
        struct tcpcb tcpcb;
@@ -262,16 +262,10 @@ read_ns(void)
 again:
        KREAD(off, &pcbtable, sizeof (struct inpcbtable));
 
-       prev = head = (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue;
        next = TAILQ_FIRST(&pcbtable.inpt_queue);
 
-       while (next != head) {
+       while (next != NULL) {
                KREAD(next, &inpcb, sizeof (inpcb));
-               if (TAILQ_PREV(&inpcb, inpthead, inp_queue) != prev) {
-                       error("Kernel state in transition");
-                       return 0;
-               }
-               prev = next;
                next = TAILQ_NEXT(&inpcb, inp_queue);
 
                if (!aflag) {
index ce295c5..6ae22ec 100644 (file)
@@ -290,7 +290,7 @@ static u_long
 kfind_tcb(int sock)
 {
        struct inpcbtable tcbtab;
-       struct inpcb *head, *next, *prev;
+       struct inpcb *next, *prev;
        struct inpcb inpcb;
        struct tcpcb tcpcb;
 
@@ -322,24 +322,15 @@ kfind_tcb(int sock)
                fprintf(stderr, "Using PCB table at %lu\n", ptb->ktcbtab);
 retry:
        kget(ptb->ktcbtab, &tcbtab, sizeof(tcbtab));
-       prev = head = (struct inpcb *)&TAILQ_FIRST(
-           &((struct inpcbtable *)ptb->ktcbtab)->inpt_queue);
+       prev = NULL;
        next = TAILQ_FIRST(&tcbtab.inpt_queue);
 
        if (ptb->vflag >= 2)
-               fprintf(stderr, "PCB head at %p\n", head);
-       while (next != head) {
+               fprintf(stderr, "PCB start at %p\n", next);
+       while (next != NULL) {
                if (ptb->vflag >= 2)
                        fprintf(stderr, "Checking PCB %p\n", next);
                kget((u_long)next, &inpcb, sizeof(inpcb));
-               if (TAILQ_PREV(&inpcb, inpthead, inp_queue) != prev) {
-                       if (nretry--) {
-                               warnx("pcb prev pointer insane");
-                               goto retry;
-                       } else
-                               errx(1, "pcb prev pointer insane,"
-                                    " all attempts exausted");
-               }
                prev = next;
                next = TAILQ_NEXT(&inpcb, inp_queue);