diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2017-04-26 15:51:00 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2017-04-26 15:51:00 +0000 |
commit | e6f8e536ed06b66bbbb07752174e78e055d12fad (patch) | |
tree | 7bcba606b88e6c2836bdc1ab5b087d447fe479c9 /sys/net/hfsc.c | |
parent | 606f6c2f05e79d2203a511379076bc2fa1ccd830 (diff) |
Perform H-FSC root queue allocation in the kernel
Since only leaf queues can have packets assigned to them,
H-FSC requires the user specified root queue to have a
parent. To simplify userland tools and the configuration
interface, the kernel can be leveraged to set it up.
ok henning
Diffstat (limited to 'sys/net/hfsc.c')
-rw-r--r-- | sys/net/hfsc.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c index a71da8ac6a9..f28b6a5205c 100644 --- a/sys/net/hfsc.c +++ b/sys/net/hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hfsc.c,v 1.36 2017/03/07 01:29:53 dlg Exp $ */ +/* $OpenBSD: hfsc.c,v 1.37 2017/04/26 15:50:59 mikeb Exp $ */ /* * Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org> @@ -349,10 +349,12 @@ hfsc_pf_addqueue(struct hfsc_if *hif, struct pf_queuespec *q) KASSERT(hif != NULL); - if (q->parent_qid == HFSC_NULLCLASS_HANDLE && - hif->hif_rootclass == NULL) - parent = NULL; - else if ((parent = hfsc_clh2cph(hif, q->parent_qid)) == NULL) + if (q->parent_qid == 0 && hif->hif_rootclass == NULL) { + parent = hfsc_class_create(hif, NULL, NULL, NULL, NULL, + 0, 0, HFSC_ROOT_CLASS | q->qid); + if (parent == NULL) + return (EINVAL); + } else if ((parent = hfsc_clh2cph(hif, q->parent_qid)) == NULL) return (EINVAL); if (q->qid == 0) @@ -446,17 +448,22 @@ void hfsc_free(unsigned int idx, void *q) { struct hfsc_if *hif = q; - int i; + struct hfsc_class *cl; + int i, restart; KERNEL_ASSERT_LOCKED(); KASSERT(idx == 0); /* when hfsc is enabled we only use the first ifq */ timeout_del(&hif->hif_defer); - i = hif->hif_allocated; - do - hfsc_class_destroy(hif, hif->hif_class_tbl[--i]); - while (i > 0); + do { + restart = 0; + for (i = 0; i < hif->hif_allocated; i++) { + cl = hif->hif_class_tbl[i]; + if (hfsc_class_destroy(hif, cl) == EBUSY) + restart++; + } + } while (restart > 0); free(hif->hif_class_tbl, M_DEVBUF, hif->hif_allocated * sizeof(void *)); free(hif, M_DEVBUF, sizeof(*hif)); |