From dc367dedac6a4ec8a7f45b42f980a09fbb0b273e Mon Sep 17 00:00:00 2001 From: Kenjiro Cho Date: Tue, 26 Nov 2002 03:44:54 +0000 Subject: fix "pfctl -Fq". after altq gets flushed, altq forgot that it was enabled since altq is actually detached with an empty ruleset. so, add a variable, pfaltq_running, to remember the running state and re-enable altq when a new ruleset is loaded. noticed, tested, and oked by henning@ --- sys/altq/altq_subr.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'sys/altq/altq_subr.c') diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index f6fa7f72ae9..96556e6c41e 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_subr.c,v 1.10 2002/11/26 01:03:34 henning Exp $ */ +/* $OpenBSD: altq_subr.c,v 1.11 2002/11/26 03:44:53 kjc Exp $ */ /* $KAME: altq_subr.c,v 1.11 2002/01/11 08:11:49 kjc Exp $ */ /* @@ -107,6 +107,8 @@ int (*altq_input)(struct mbuf *, int) = NULL; static int tbr_timer = 0; /* token bucket regulator timer */ static struct callout tbr_callout = CALLOUT_INITIALIZER; +int pfaltq_running; /* keep track of running state */ + /* * alternate queueing support routines */ @@ -449,9 +451,16 @@ altq_pfattach(struct pf_altq *a) error = EINVAL; } + ifp = ifunit(a->ifname); + + /* if the state is running, enable altq */ + if (error == 0 && pfaltq_running && + ifp != NULL && ifp->if_snd.altq_type != ALTQT_NONE && + !ALTQ_IS_ENABLED(&ifp->if_snd)) + error = altq_enable(&ifp->if_snd); + /* if altq is already enabled, reset set tokenbucket regulator */ - if (error == 0 && (ifp = ifunit(a->ifname)) != NULL && - ALTQ_IS_ENABLED(&ifp->if_snd)) { + if (error == 0 && ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) { tb.rate = a->ifbandwidth; tb.depth = a->tbrsize; s = splimp(); -- cgit v1.2.3