diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2008-10-08 15:11:14 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2008-10-08 15:11:14 +0000 |
commit | 007bb06efaccf78efc54677d7a4a97c2a1fab6de (patch) | |
tree | 94a58a1bacc17da8acb9ebae9f6b74a7ef300665 | |
parent | 0fc65faf178148be82085611e137644a38eb410d (diff) |
Fix the order of traversal when printing the queues. Properly places
child queues under their respective interface root queues. Reported
by jared r r spiegel via PR 5861.
-rw-r--r-- | usr.bin/systat/pftop.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/usr.bin/systat/pftop.c b/usr.bin/systat/pftop.c index e69e117bcd0..84b61486ed8 100644 --- a/usr.bin/systat/pftop.c +++ b/usr.bin/systat/pftop.c @@ -1,4 +1,4 @@ -/* $Id: pftop.c,v 1.5 2008/09/01 23:30:08 sthen Exp $ */ +/* $Id: pftop.c,v 1.6 2008/10/08 15:11:13 canacar Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier @@ -58,6 +58,7 @@ #include <unistd.h> #include <stdarg.h> +#include "systat.h" #include "engine.h" #include "cache.h" @@ -1516,12 +1517,19 @@ pfctl_insert_altq_node(struct pf_altq_node **root, prev->next = node; } } - if (*root != node) { - struct pf_altq_node *prev_flat = *root; - while (prev_flat->next_flat != NULL) { - prev_flat = prev_flat->next_flat; - } - prev_flat->next_flat = node; +} + +void +pfctl_set_next_flat(struct pf_altq_node *node, struct pf_altq_node *up) +{ + while (node) { + struct pf_altq_node *next = node->next ? node->next : up; + if (node->children) { + node->next_flat = node->children; + pfctl_set_next_flat(node->children, next); + } else + node->next_flat = next; + node = node->next; } } @@ -1534,6 +1542,7 @@ pfctl_update_qstats(struct pf_altq_node **root, int *inserts) u_int32_t nr; struct queue_stats qstats; u_int32_t nr_queues; + int ret = 0; *inserts = 0; memset(&pa, 0, sizeof(pa)); @@ -1547,12 +1556,14 @@ pfctl_update_qstats(struct pf_altq_node **root, int *inserts) error("DIOCGETALTQS: %s", strerror(errno)); return (-1); } + num_queues = nr_queues = pa.nr; for (nr = 0; nr < nr_queues; ++nr) { pa.nr = nr; if (ioctl(pf_dev, DIOCGETALTQ, &pa)) { error("DIOCGETALTQ: %s", strerror(errno)); - return (-1); + ret = -1; + break; } if (pa.altq.qid > 0) { pq.nr = nr; @@ -1561,7 +1572,8 @@ pfctl_update_qstats(struct pf_altq_node **root, int *inserts) pq.nbytes = sizeof(qstats); if (ioctl(pf_dev, DIOCGETQSTATS, &pq)) { error("DIOCGETQSTATS: %s", strerror(errno)); - return (-1); + ret = -1; + break; } qstats.valid = 1; gettimeofday(&qstats.timestamp, NULL); @@ -1582,7 +1594,10 @@ pfctl_update_qstats(struct pf_altq_node **root, int *inserts) else --num_queues; } - return (0); + + pfctl_set_next_flat(*root, NULL); + + return (ret); } void |