-/* $OpenBSD: hfsc.c,v 1.5 2014/01/01 17:46:43 pelikan Exp $ */
+/* $OpenBSD: hfsc.c,v 1.6 2014/01/03 12:48:58 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
#include <sys/param.h>
#include <sys/malloc.h>
+#include <sys/pool.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/systm.h>
if (hif->hif_classes >= HFSC_MAX_CLASSES)
return (NULL);
- cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK|M_ZERO);
- cl->cl_q = malloc(sizeof(struct hfsc_classq), M_DEVBUF,
- M_WAITOK|M_ZERO);
+ cl = pool_get(&hfsc_class_pl, PR_WAITOK | PR_ZERO);
+ cl->cl_q = pool_get(&hfsc_classq_pl, PR_WAITOK | PR_ZERO);
cl->cl_actc = hfsc_actlist_alloc();
if (qlimit == 0)
#endif /* RED_NOTYET */
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) {
- cl->cl_rsc = malloc(sizeof(struct hfsc_internal_sc), M_DEVBUF,
- M_WAITOK);
+ cl->cl_rsc = pool_get(&hfsc_internal_sc_pl, PR_WAITOK);
hfsc_sc2isc(rsc, cl->cl_rsc);
hfsc_rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0);
hfsc_rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0);
}
if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) {
- cl->cl_fsc = malloc(sizeof(struct hfsc_internal_sc), M_DEVBUF,
- M_WAITOK);
+ cl->cl_fsc = pool_get(&hfsc_internal_sc_pl, PR_WAITOK);
hfsc_sc2isc(fsc, cl->cl_fsc);
hfsc_rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0);
}
if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) {
- cl->cl_usc = malloc(sizeof(struct hfsc_internal_sc), M_DEVBUF,
- M_WAITOK);
+ cl->cl_usc = pool_get(&hfsc_internal_sc_pl, PR_WAITOK);
hfsc_sc2isc(usc, cl->cl_usc);
hfsc_rtsc_init(&cl->cl_ulimit, cl->cl_usc, 0, 0);
}
}
#endif
if (cl->cl_fsc != NULL)
- free(cl->cl_fsc, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_fsc);
if (cl->cl_rsc != NULL)
- free(cl->cl_rsc, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_rsc);
if (cl->cl_usc != NULL)
- free(cl->cl_usc, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_usc);
if (cl->cl_q != NULL)
- free(cl->cl_q, M_DEVBUF);
- free(cl, M_DEVBUF);
+ pool_put(&hfsc_classq_pl, cl->cl_q);
+ pool_put(&hfsc_class_pl, cl);
return (NULL);
}
cl->cl_hif->hif_defaultclass = NULL;
if (cl->cl_usc != NULL)
- free(cl->cl_usc, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_usc);
if (cl->cl_fsc != NULL)
- free(cl->cl_fsc, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_fsc);
if (cl->cl_rsc != NULL)
- free(cl->cl_rsc, M_DEVBUF);
- free(cl->cl_q, M_DEVBUF);
- free(cl, M_DEVBUF);
+ pool_put(&hfsc_internal_sc_pl, cl->cl_rsc);
+ pool_put(&hfsc_classq_pl, cl->cl_q);
+ pool_put(&hfsc_class_pl, cl);
return (0);
}
-/* $OpenBSD: pf.c,v 1.862 2013/11/18 20:30:04 bluhm Exp $ */
+/* $OpenBSD: pf.c,v 1.863 2014/01/03 12:48:58 pelikan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
struct pool pf_src_tree_pl, pf_rule_pl, pf_queue_pl;
struct pool pf_state_pl, pf_state_key_pl, pf_state_item_pl;
struct pool pf_altq_pl, pf_rule_item_pl, pf_sn_item_pl;
+struct pool hfsc_class_pl, hfsc_classq_pl, hfsc_internal_sc_pl;
void pf_init_threshold(struct pf_threshold *, u_int32_t,
u_int32_t);
-/* $OpenBSD: pf_ioctl.c,v 1.266 2014/01/03 12:43:09 pelikan Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.267 2014/01/03 12:48:58 pelikan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
&pool_allocator_nointr);
pool_init(&pf_queue_pl, sizeof(struct pf_queuespec), 0, 0, 0,
"pfqueuepl", NULL);
+ pool_init(&hfsc_class_pl, sizeof(struct hfsc_class), 0, 0, PR_WAITOK,
+ "hfscclass", NULL);
+ pool_init(&hfsc_classq_pl, sizeof(struct hfsc_classq), 0, 0, PR_WAITOK,
+ "hfscclassq", NULL);
+ pool_init(&hfsc_internal_sc_pl, sizeof(struct hfsc_internal_sc), 0, 0,
+ PR_WAITOK, "hfscintsc", NULL);
pfr_initialize();
pfi_initialize();
pf_osfp_initialize();
-/* $OpenBSD: pfvar.h,v 1.394 2014/01/03 12:43:09 pelikan Exp $ */
+/* $OpenBSD: pfvar.h,v 1.395 2014/01/03 12:48:58 pelikan Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
extern struct pool pf_state_pl, pf_state_key_pl, pf_state_item_pl,
pf_altq_pl, pf_rule_item_pl, pf_queue_pl;
extern struct pool pf_state_scrub_pl;
+extern struct pool hfsc_class_pl, hfsc_classq_pl,
+ hfsc_internal_sc_pl;
extern void pf_purge_thread(void *);
extern void pf_purge_expired_src_nodes(int);
extern void pf_purge_expired_states(u_int32_t);