summaryrefslogtreecommitdiff
path: root/sys/net/pf.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-06-25 19:22:27 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-06-25 19:22:27 +0000
commit0adcef35c587a06d6141cdf97085590422facafd (patch)
treeba515016fd81585f22586b81e24b7d154eb1ee00 /sys/net/pf.c
parent59a7dc2512843eddac1756b92c453337ac2a1357 (diff)
Rework COMMITRULES.
First we swap in the new rules, then we free the old (freeing can be done outside splnet).
Diffstat (limited to 'sys/net/pf.c')
-rw-r--r--sys/net/pf.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c
index 9050c8977ab..a3b03e00d4e 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.33 2001/06/25 17:17:04 dhartmei Exp $ */
+/* $OpenBSD: pf.c,v 1.34 2001/06/25 19:22:26 art Exp $ */
/*
* Copyright (c) 2001, Daniel Hartmeier
@@ -601,23 +601,31 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
case DIOCCOMMITRULES: {
u_int32_t *ticket = (u_int32_t *)addr;
+ struct pf_rule *old_rules;
if (*ticket != ticket_rules_inactive) {
error = EBUSY;
goto done;
}
+
+ /* Swap rules, keep the old. */
s = splsoftnet();
- while (pf_rulehead_active != NULL) {
- struct pf_rule *next = pf_rulehead_active->next;
- pool_put(&pf_rule_pl, pf_rulehead_active);
- pf_rulehead_active = next;
- }
+ old_rules = pf_rulehead_active;
pf_rulehead_active = pf_rulehead_inactive;
pf_ruletail_active = pf_ruletail_inactive;
pf_rulehead_inactive = NULL;
pf_ruletail_inactive = NULL;
ticket_rules_active = ticket_rules_inactive;
splx(s);
+
+ /* Purge the old rule list. */
+ while (old_rules != NULL) {
+ struct pf_rule *next = old_rules->next;
+
+ pool_put(&pf_rule_pl, old_rules);
+ old_rules = next;
+ }
+
break;
}