From: tedu Date: Tue, 24 Dec 2013 22:26:19 +0000 (+0000) Subject: more fixing after circleq conversion. a better fix to check the prev X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c46eaf98a22429668aee87eb6999ad32cfde0337;p=openbsd more fixing after circleq conversion. a better fix to check the prev pointer is forthcoming. --- diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 685212250e1..070c6da6334 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -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); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 652aa32f94d..3f4f38e2aeb 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -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) { diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c index ce295c5319d..6ae22ec7a42 100644 --- a/usr.bin/tcpbench/tcpbench.c +++ b/usr.bin/tcpbench/tcpbench.c @@ -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);