diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-13 20:16:07 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-13 20:16:07 +0000 |
commit | 8eb1dafdd0f9eec7c42d6f64c12136246e1c035c (patch) | |
tree | 28e72829ef4c9bf05302b3bd5927a0003c062f67 /sbin/pfctl/pfctl_altq.c | |
parent | c2189dae8d80d37c6a8b1288843dbb5724924787 (diff) |
pass down the struct node_queue_opts from the altqif/queuespec yacc targets
to expand_altq/expand_queue -> eval_pfaltq/eval_pfqueue and
further down to the new eval_queue_opts() instead of evaluating them directly
in the yacc grammar.
this will be needed to process the hfsc options which can contain relative
bandwidth specifications, and we can't break them down to an absolute one
earlier.
Diffstat (limited to 'sbin/pfctl/pfctl_altq.c')
-rw-r--r-- | sbin/pfctl/pfctl_altq.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c index cc7a885be8c..444ef9e5351 100644 --- a/sbin/pfctl/pfctl_altq.c +++ b/sbin/pfctl/pfctl_altq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_altq.c,v 1.59 2003/04/13 19:36:00 henning Exp $ */ +/* $OpenBSD: pfctl_altq.c,v 1.60 2003/04/13 20:16:06 henning Exp $ */ /* * Copyright (C) 2002 @@ -84,6 +84,8 @@ static double sc_x2y(struct service_curve *, double); u_int32_t getifspeed(char *); u_long getifmtu(char *); +int eval_queue_opts(struct pf_altq *, struct node_queue_opt *, + u_int32_t); static u_int32_t max_qid = 1; @@ -232,7 +234,8 @@ print_queue(const struct pf_altq *a, unsigned level, u_int16_t bwpercent, * eval_pfaltq computes the discipline parameters. */ int -eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw) +eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw, + struct node_queue_opt *opts) { u_int rate, size, errors = 0; @@ -250,6 +253,8 @@ eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw) else pa->ifbandwidth = rate; + errors += eval_queue_opts(pa, opts, rate); + /* if tbrsize is not specified, use heuristics */ if (pa->tbrsize == 0) { rate = pa->ifbandwidth; @@ -301,7 +306,8 @@ check_commit_altq(int dev, int opts) * eval_pfqueue computes the queue parameters. */ int -eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw) +eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw, + struct node_queue_opt *opts) { /* should be merged with expand_queue */ struct pf_altq *if_pa, *parent; @@ -359,6 +365,9 @@ eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw) } } + if (eval_queue_opts(pa, opts, parent == NULL? 0 : parent->bandwidth)) + return (1); + switch (pa->scheduler) { case ALTQT_CBQ: error = eval_pfqueue_cbq(pf, pa); @@ -1122,3 +1131,29 @@ getifmtu(char *ifname) return (1500); } } + +int +eval_queue_opts(struct pf_altq *pa, struct node_queue_opt *opts, + u_int32_t ref_bw) +{ + int errors = 0; + + switch (pa->scheduler) { + case ALTQT_CBQ: + pa->pq_u.cbq_opts = opts->data.cbq_opts; + break; + case ALTQT_PRIQ: + pa->pq_u.priq_opts = opts->data.priq_opts; + break; + case ALTQT_HFSC: + pa->pq_u.hfsc_opts.flags = opts->data.hfsc_opts.flags; + break; + default: + warnx("eval_queue_opts: unknown scheduler type %u", + opts->qtype); + errors++; + break; + } + + return (errors); +} |