Skip to content

Commit 8fecb09

Browse files
committed
pfctl: store correct ticket type
When loading a new rule only persist the ticket if we're actually looking at a filter rule. We need that ticket type later if we have to create tables, but we need the ticket for the correct ruleset. Fixes: 9dfc5e0 ("pfctl: allow tables to be defined inside anchors") Reported by: Florian Smeets <[email protected]> MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate")
1 parent c943e6f commit 8fecb09

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sbin/pfctl/pfctl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,7 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pfctl_rule *r, int depth)
21832183
{
21842184
u_int8_t rs_num = pf_get_ruleset_number(r->action);
21852185
char *name;
2186+
uint32_t ticket;
21862187
char anchor[PF_ANCHOR_NAME_SIZE];
21872188
int len = strlen(path);
21882189
int error;
@@ -2192,7 +2193,9 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pfctl_rule *r, int depth)
21922193
if ((pf->opts & PF_OPT_NOACTION) == 0) {
21932194
if (pf->trans == NULL)
21942195
errx(1, "pfctl_load_rule: no transaction");
2195-
pf->anchor->ruleset.tticket = pfctl_get_ticket(pf->trans, rs_num, path);
2196+
ticket = pfctl_get_ticket(pf->trans, rs_num, path);
2197+
if (rs_num == PF_RULESET_FILTER)
2198+
pf->anchor->ruleset.tticket = ticket;
21962199
}
21972200
if (strlcpy(anchor, path, sizeof(anchor)) >= sizeof(anchor))
21982201
errx(1, "pfctl_load_rule: strlcpy");
@@ -2225,7 +2228,7 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pfctl_rule *r, int depth)
22252228
return (1);
22262229
if (pfctl_add_pool(pf, &r->route, PF_RT))
22272230
return (1);
2228-
error = pfctl_add_rule_h(pf->h, r, anchor, name, pf->anchor->ruleset.tticket,
2231+
error = pfctl_add_rule_h(pf->h, r, anchor, name, ticket,
22292232
pf->paddr.ticket);
22302233
switch (error) {
22312234
case 0:

0 commit comments

Comments
 (0)