summaryrefslogtreecommitdiff
path: root/sys/altq
diff options
context:
space:
mode:
Diffstat (limited to 'sys/altq')
-rw-r--r--sys/altq/altq_cbq.c28
-rw-r--r--sys/altq/altq_hfsc.c36
-rw-r--r--sys/altq/altq_priq.c22
3 files changed, 59 insertions, 27 deletions
diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c
index 6b1e96d3eb5..0eb98af1dfd 100644
--- a/sys/altq/altq_cbq.c
+++ b/sys/altq/altq_cbq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_cbq.c,v 1.12 2003/02/05 17:43:12 henning Exp $ */
+/* $OpenBSD: altq_cbq.c,v 1.13 2003/03/02 11:22:31 henning Exp $ */
/* $KAME: altq_cbq.c,v 1.9 2000/12/14 08:12:45 thorpej Exp $ */
/*
@@ -332,14 +332,24 @@ cbq_add_queue(struct pf_altq *a)
chandle = CTL_CLASS_HANDLE;
break;
case 0:
- /* find a free class slot. for now, reserve qid 0 */
- for (i = 1; i < CBQ_MAX_CLASSES; i++)
- if (cbqp->cbq_class_tbl[i] == NULL)
- break;
- if (i == CBQ_MAX_CLASSES)
- return (ENOSPC);
- chandle = (u_int32_t)i;
- break;
+ if (a->qid) {
+ chandle = a->qid;
+ if (chandle >= CBQ_MAX_CLASSES &&
+ chandle != DEFAULT_CLASS_HANDLE &&
+ chandle != CTL_CLASS_HANDLE)
+ return (EINVAL);
+ if (cbqp->cbq_class_tbl[chandle] != NULL)
+ return (EBUSY);
+ } else {
+ /* find a free class slot. for now, reserve qid 0 */
+ for (i = 1; i < CBQ_MAX_CLASSES; i++)
+ if (cbqp->cbq_class_tbl[i] == NULL)
+ break;
+ if (i == CBQ_MAX_CLASSES)
+ return (ENOSPC);
+ chandle = (u_int32_t)i;
+ }
+ break;
default:
/* more than two flags bits set */
return (EINVAL);
diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c
index f02b5e9de57..eb844cb7daa 100644
--- a/sys/altq/altq_hfsc.c
+++ b/sys/altq/altq_hfsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_hfsc.c,v 1.9 2002/12/16 17:27:20 henning Exp $ */
+/* $OpenBSD: altq_hfsc.c,v 1.10 2003/03/02 11:22:31 henning Exp $ */
/* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */
/*
@@ -68,7 +68,7 @@ static int hfsc_request(struct ifaltq *, int, void *);
static void hfsc_purge(struct hfsc_if *);
static struct hfsc_class *hfsc_class_create(struct hfsc_if *,
struct service_curve *, struct service_curve *, struct service_curve *,
- struct hfsc_class *, int, int);
+ struct hfsc_class *, int, int, int);
static int hfsc_class_destroy(struct hfsc_class *);
static struct hfsc_class *hfsc_nextclass(struct hfsc_class *);
static int hfsc_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *);
@@ -175,7 +175,7 @@ hfsc_add_altq(struct pf_altq *a)
root_sc.d = 0;
root_sc.m2 = a->ifbandwidth;
if ((hif->hif_rootclass = hfsc_class_create(hif,
- &root_sc, &root_sc, NULL, NULL, 0, 0)) == NULL) {
+ &root_sc, &root_sc, NULL, NULL, 0, 0, 0)) == NULL) {
FREE(hif, M_DEVBUF);
return (ENOMEM);
}
@@ -221,6 +221,12 @@ hfsc_add_queue(struct pf_altq *a)
parent = clh_to_clp(hif, a->parent_qid);
if (parent == NULL)
return (EINVAL);
+ if (a->qid != 0) {
+ if (a->qid >= HFSC_MAX_CLASSES)
+ return (EINVAL);
+ if (clh_to_clp(hif, a->qid) != NULL)
+ return (EBUSY);
+ }
rtsc.m1 = opts->rtsc_m1;
rtsc.d = opts->rtsc_d;
rtsc.m2 = opts->rtsc_m2;
@@ -232,7 +238,7 @@ hfsc_add_queue(struct pf_altq *a)
ulsc.m2 = opts->ulsc_m2;
cl = hfsc_class_create(hif, &rtsc, &lssc, &ulsc,
- parent, a->qlimit, opts->flags);
+ parent, a->qlimit, opts->flags, a->qid);
if (cl == NULL)
return (ENOMEM);
@@ -340,11 +346,11 @@ hfsc_purge(hif)
}
struct hfsc_class *
-hfsc_class_create(hif, rsc, fsc, usc, parent, qlimit, flags)
+hfsc_class_create(hif, rsc, fsc, usc, parent, qlimit, flags, qid)
struct hfsc_if *hif;
struct service_curve *rsc, *fsc, *usc;
struct hfsc_class *parent;
- int qlimit, flags;
+ int qlimit, flags, qid;
{
struct hfsc_class *cl, *p;
int i, s, chandle;
@@ -358,13 +364,17 @@ hfsc_class_create(hif, rsc, fsc, usc, parent, qlimit, flags)
}
#endif
- /* find a free class slot. */
- for (i = 0; i < HFSC_MAX_CLASSES; i++)
- if (hif->hif_class_tbl[i] == NULL)
- break;
- if (i == HFSC_MAX_CLASSES)
- return (NULL);
- chandle = i + 1;
+ if (qid)
+ chandle = qid;
+ else {
+ /* find a free class slot. */
+ for (i = 0; i < HFSC_MAX_CLASSES; i++)
+ if (hif->hif_class_tbl[i] == NULL)
+ break;
+ if (i == HFSC_MAX_CLASSES)
+ return (NULL);
+ chandle = i + 1;
+ }
MALLOC(cl, struct hfsc_class *, sizeof(struct hfsc_class),
M_DEVBUF, M_WAITOK);
diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c
index e856a4c790e..109686b4826 100644
--- a/sys/altq/altq_priq.c
+++ b/sys/altq/altq_priq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_priq.c,v 1.9 2003/02/08 13:05:43 henning Exp $ */
+/* $OpenBSD: altq_priq.c,v 1.10 2003/03/02 11:22:31 henning Exp $ */
/* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */
/*
* Copyright (C) 2000
@@ -52,7 +52,8 @@
static int priq_clear_interface(struct priq_if *);
static int priq_request(struct ifaltq *, int, void *);
static void priq_purge(struct priq_if *);
-static struct priq_class *priq_class_create(struct priq_if *, int, int, int);
+static struct priq_class *priq_class_create(struct priq_if *, int, int, int,
+ int);
static int priq_class_destroy(struct priq_class *);
static int priq_enqueue(struct ifaltq *, struct mbuf *,
struct altq_pktattr *);
@@ -135,8 +136,16 @@ priq_add_queue(struct pf_altq *a)
if (a->priority >= PRIQ_MAXPRI)
return (EINVAL);
+ if (a->qid != 0) {
+ /* qid is tied to priority with priq */
+ if (a->qid != a->priority + 1)
+ return (EINVAL);
+ if (clh_to_clp(pif, a->qid) != NULL)
+ return (EBUSY);
+ }
+
cl = priq_class_create(pif, a->priority, a->qlimit,
- a->pq_u.priq_opts.flags);
+ a->pq_u.priq_opts.flags, a->qid);
if (cl == NULL)
return (ENOMEM);
@@ -236,7 +245,7 @@ priq_purge(struct priq_if *pif)
}
static struct priq_class *
-priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags)
+priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid)
{
struct priq_class *cl;
int s;
@@ -291,7 +300,10 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags)
if (pri > pif->pif_maxpri)
pif->pif_maxpri = pri;
cl->cl_pif = pif;
- cl->cl_handle = pri + 1;
+ if (qid)
+ cl->cl_handle = qid;
+ else
+ cl->cl_handle = pri + 1;
#ifdef ALTQ_RED
if (flags & (PRCF_RED|PRCF_RIO)) {