Apart from some minor code reshuffling the big change is that we
authormikeb <mikeb@openbsd.org>
Tue, 12 Aug 2014 14:38:27 +0000 (14:38 +0000)
committermikeb <mikeb@openbsd.org>
Tue, 12 Aug 2014 14:38:27 +0000 (14:38 +0000)
start with a ruleset pointer assigned to pf_main_ruleset so that
pf_purge_rule doesn't get called with a NULL.

Prompted by the discussion with Alexandr Nedvedicky <alexandr !
nedvedicky at oracle ! com>.

OK henning

sys/net/pf.c
sys/net/pf_ioctl.c

index a5d9aad..dae2d8b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pf.c,v 1.883 2014/07/22 11:06:09 mpi Exp $ */
+/*     $OpenBSD: pf.c,v 1.884 2014/08/12 14:38:27 mikeb Exp $ */
 
 /*
  * Copyright (c) 2001 Daniel Hartmeier
@@ -3165,6 +3165,7 @@ pf_test_rule(struct pf_pdesc *pd, struct pf_rule **rm, struct pf_state **sm,
 #endif /* INET6 */
        }
 
+       ruleset = &pf_main_ruleset;
        r = TAILQ_FIRST(pf_main_ruleset.rules.active.ptr);
        while (r != NULL) {
                r->evaluations++;
index 735ff7d..a4dba03 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pf_ioctl.c,v 1.274 2014/07/22 11:06:09 mpi Exp $ */
+/*     $OpenBSD: pf_ioctl.c,v 1.275 2014/08/12 14:38:28 mikeb Exp $ */
 
 /*
  * Copyright (c) 2001 Daniel Hartmeier
@@ -309,20 +309,15 @@ pf_rm_rule(struct pf_rulequeue *rulequeue, struct pf_rule *rule)
 void
 pf_purge_rule(struct pf_ruleset *ruleset, struct pf_rule *rule)
 {
-       u_int32_t                nr;
+       u_int32_t        nr = 0;
 
-       if (ruleset == NULL || ruleset->anchor == NULL)
-               return;
+       KASSERT(ruleset != NULL && rule != NULL);
 
        pf_rm_rule(ruleset->rules.active.ptr, rule);
        ruleset->rules.active.rcount--;
-
-       nr = 0;
        TAILQ_FOREACH(rule, ruleset->rules.active.ptr, entries)
                rule->nr = nr++;
-
        ruleset->rules.active.ticket++;
-
        pf_calc_skip_steps(ruleset->rules.active.ptr);
        pf_remove_if_empty_ruleset(ruleset);
 }