If an anchor/ruleset contains no rules, there is no point in creating
a temporary copy, optimizing and replacing it.
Regress passes on amd64.
Feedback? OK?
Index: pfctl_optimize.c
===================================================================
RCS file: /cvs/src/sbin/pfctl/pfctl_optimize.c,v
retrieving revision 1.42
diff -u -p -r1.42 pfctl_optimize.c
--- pfctl_optimize.c 28 Jun 2019 13:32:45 -0000 1.42
+++ pfctl_optimize.c 27 Nov 2019 18:53:23 -0000
@@ -270,6 +270,9 @@ pfctl_optimize_ruleset(struct pfctl *pf,
struct pf_rule *r;
struct pf_rulequeue *old_rules;
+ if (TAILQ_EMPTY(rs->rules.active.ptr))
+ return (0);
+
DEBUG("optimizing ruleset");
memset(&table_buffer, 0, sizeof(table_buffer));
skip_init();