diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-03 14:31:03 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-03 14:31:03 +0000 |
commit | d145bb27e040bffbed5e30d2ebdab24a98eeeb81 (patch) | |
tree | febf2be42bfe7fe0ae6c079c495e5e2d9df6c0d4 /sys/altq | |
parent | 5c768ec5c3f404ee20b4f0aec19b339d0a1ee96b (diff) |
until now, the queue ID and the priority were tied together with PRIQ. this
diff changes that.
with PRIQ, the queues are in an array, with the priority as key. removing
the tie means we cannot access the array with (queueID - 1) as key any
more but need to traverse the array until the queue ID matches. As the array
has a maximum of 16 entries, traversing linear is okay.
a new queue ID allocation algorithm coming soon will require this.
ok dhartmei@ kjc@
Diffstat (limited to 'sys/altq')
-rw-r--r-- | sys/altq/altq_priq.c | 20 | ||||
-rw-r--r-- | sys/altq/altq_priq.h | 3 |
2 files changed, 12 insertions, 11 deletions
diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index f359d71321f..59d212cc586 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.c,v 1.15 2003/04/02 16:17:42 henning Exp $ */ +/* $OpenBSD: altq_priq.c,v 1.16 2003/04/03 14:31:02 henning Exp $ */ /* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000 @@ -135,12 +135,9 @@ priq_add_queue(struct pf_altq *a) /* check parameters */ if (a->priority >= PRIQ_MAXPRI) return (EINVAL); - if (a->qid == 0) return (EINVAL); - - /* qid is tied to priority with priq */ - if (a->qid != a->priority + 1) + if (a->qid > PRIQ_MAXQID) return (EINVAL); if (clh_to_clp(pif, a->qid) != NULL) return (EBUSY); @@ -564,12 +561,15 @@ get_class_stats(struct priq_classstats *sp, struct priq_class *cl) static struct priq_class * clh_to_clp(struct priq_if *pif, u_int32_t chandle) { - u_int idx; + int idx; if (chandle == 0) return (NULL); - idx = chandle - 1; - if (idx >= PRIQ_MAXPRI) - return (NULL); - return (pif->pif_classes[idx]); + + for (idx = pif->pif_maxpri; idx >= 0; idx--) + if (pif->pif_classes[idx] != NULL && + pif->pif_classes[idx]->cl_handle == chandle) + return (pif->pif_classes[idx]); + + return (NULL); } diff --git a/sys/altq/altq_priq.h b/sys/altq/altq_priq.h index dc6e5a4be5d..7e3628b6353 100644 --- a/sys/altq/altq_priq.h +++ b/sys/altq/altq_priq.h @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.h,v 1.4 2002/12/16 17:27:20 henning Exp $ */ +/* $OpenBSD: altq_priq.h,v 1.5 2003/04/03 14:31:02 henning Exp $ */ /* $KAME: altq_priq.h,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000-2002 @@ -39,6 +39,7 @@ extern "C" { #endif #define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ +#define PRIQ_MAXQID 256 /* upper limit of queues */ /* priq class flags */ #define PRCF_RED 0x0001 /* use RED */ |