summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-03-02 23:37:25 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-03-02 23:37:25 +0000
commitad32c5e5312d7849dc07ea3addb6c72893026a6c (patch)
tree79bd1d8ece0b4e95acd82546efa93ad8eae51d14 /sbin/pfctl
parent11a37d155b51dea710d060d2eb85c083de9208bf (diff)
when printing queues at load time that have bandwidth specified in percent,
print the bandwidth in percent instead of the calculated absolute value. if a queue belongs to more than one interface and they have different bandwidth the calculated absolute is of course different per interface. previously the first calculated absolute value was shown; what of course is incorrect on the second interface. note that only the print was wrong, the correct values were passed to the kernel. ok theo daniel
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y31
-rw-r--r--sbin/pfctl/pfctl.h6
-rw-r--r--sbin/pfctl/pfctl_altq.c23
-rw-r--r--sbin/pfctl/pfctl_qstats.c4
4 files changed, 37 insertions, 27 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 94359254754..4fae66177a9 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.334 2003/03/02 12:37:49 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.335 2003/03/02 23:37:24 henning Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -3059,7 +3059,8 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces,
errs++;
if (pf->opts & PF_OPT_VERBOSE) {
- print_altq(&pf->paltq->altq, 0);
+ print_altq(&pf->paltq->altq, 0,
+ bwspec.bw_percent);
if (nqueues && nqueues->tail) {
printf("queue { ");
LOOP_THROUGH(struct node_queue, queue,
@@ -3208,22 +3209,22 @@ expand_queue(struct pf_altq *a, struct node_queue *nqueues,
bwspec.bw_percent))
if (!pfctl_add_altq(pf, a))
added++;
-
- if ((pf->opts & PF_OPT_VERBOSE) && found == 1) {
- print_altq(&pf->paltq->altq, 0);
- if (nqueues && nqueues->tail) {
- printf("{ ");
- LOOP_THROUGH(struct node_queue, queue,
- nqueues,
- printf("%s ", queue->queue);
- );
- printf("}");
- }
- printf("\n");
- }
}
);
+ if ((pf->opts & PF_OPT_VERBOSE) && found > 0) {
+ print_altq(&pf->paltq->altq, 0, bwspec.bw_percent);
+ if (nqueues && nqueues->tail) {
+ printf("{ ");
+ LOOP_THROUGH(struct node_queue, queue,
+ nqueues,
+ printf("%s ", queue->queue);
+ );
+ printf("}");
+ }
+ printf("\n");
+ }
+
FREE_LIST(struct node_queue, nqueues);
if (!added) {
diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h
index 5d780e4aa1e..2772f3d2d50 100644
--- a/sbin/pfctl/pfctl.h
+++ b/sbin/pfctl/pfctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.h,v 1.10 2003/02/11 20:11:36 henning Exp $ */
+/* $OpenBSD: pfctl.h,v 1.11 2003/03/02 23:37:24 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -85,8 +85,8 @@ u_int32_t qname_to_qid(const char *, const char *);
char *qid_to_qname(u_int32_t, const char *);
char *rate2str(double);
-void print_altq(const struct pf_altq *, unsigned);
-void print_queue(const struct pf_altq *, unsigned);
+void print_altq(const struct pf_altq *, unsigned, u_int16_t);
+void print_queue(const struct pf_altq *, unsigned, u_int16_t);
void print_addr(struct pf_addr_wrap *, sa_family_t, int);
void print_host(struct pf_state_host *, sa_family_t, int);
diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c
index bb9034020bd..16ea795fbf7 100644
--- a/sbin/pfctl/pfctl_altq.c
+++ b/sbin/pfctl/pfctl_altq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_altq.c,v 1.39 2003/03/02 12:37:49 henning Exp $ */
+/* $OpenBSD: pfctl_altq.c,v 1.40 2003/03/02 23:37:24 henning Exp $ */
/*
* Copyright (C) 2002
@@ -161,10 +161,10 @@ qid_to_qname(u_int32_t qid, const char *ifname)
}
void
-print_altq(const struct pf_altq *a, unsigned level)
+print_altq(const struct pf_altq *a, unsigned level, u_int16_t bwpercent)
{
if (a->qname[0] != NULL) {
- print_queue(a, level);
+ print_queue(a, level, bwpercent);
return;
}
@@ -188,14 +188,18 @@ print_altq(const struct pf_altq *a, unsigned level)
break;
}
- printf("bandwidth %s ", rate2str((double)a->ifbandwidth));
+ if (bwpercent > 0) {
+ if (bwpercent < 100)
+ printf("bandwidth %u%% ", bwpercent);
+ } else
+ printf("bandwidth %s ", rate2str((double)a->ifbandwidth));
if (a->qlimit != DEFAULT_QLIMIT)
printf("qlimit %u ", a->qlimit);
printf("tbrsize %u ", a->tbrsize);
}
void
-print_queue(const struct pf_altq *a, unsigned level)
+print_queue(const struct pf_altq *a, unsigned level, u_int16_t bwpercent)
{
unsigned i;
@@ -203,8 +207,13 @@ print_queue(const struct pf_altq *a, unsigned level)
for (i = 0; i < level; ++i)
printf(" ");
printf("%s ", a->qname);
- if (a->scheduler == ALTQT_CBQ || a->scheduler == ALTQT_HFSC)
- printf("bandwidth %s ", rate2str((double)a->bandwidth));
+ if (a->scheduler == ALTQT_CBQ || a->scheduler == ALTQT_HFSC) {
+ if (bwpercent > 0) {
+ if (bwpercent < 100)
+ printf("bandwidth %u%% ", bwpercent);
+ } else
+ printf("bandwidth %s ", rate2str((double)a->bandwidth));
+ }
if (a->priority != DEFAULT_PRIORITY)
printf("priority %u ", a->priority);
if (a->qlimit != DEFAULT_QLIMIT)
diff --git a/sbin/pfctl/pfctl_qstats.c b/sbin/pfctl/pfctl_qstats.c
index 4e347537d15..9051f42ba20 100644
--- a/sbin/pfctl/pfctl_qstats.c
+++ b/sbin/pfctl/pfctl_qstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_qstats.c,v 1.12 2003/01/27 19:37:46 henning Exp $ */
+/* $OpenBSD: pfctl_qstats.c,v 1.13 2003/03/02 23:37:24 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer
@@ -228,7 +228,7 @@ pfctl_print_altq_node(int dev, const struct pf_altq_node *node, unsigned level,
if (node == NULL)
return;
- print_altq(&node->altq, level);
+ print_altq(&node->altq, level, 0);
if (node->children != NULL) {
printf("{");