pfctl: Report why a table definition failed

pfctl_ina_define() returns an error number instead of setting errno, but
both of its callers print errno.  A table that failed to load was
reported as "cannot define table t: No error: 0", or with a stale errno,
both in the main ruleset (process_tabledef()) and in anchors
(pfctl_load_tables()).

Reviewed by:	kp
Fixes:		219ce30638 ("pf: convert DIOCRINADEFINE to netlink")
Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
R. Christian McDonald committed 2026-10-19 16:24:36 -04:00
1 parent 067c6da5ce
commit 96944ab79a
2 files changed
+5 -4

No files matched your search

+4 -3
View File
@@ -5937,6 +5937,7 @@ process_tabledef(char *name, struct table_opts *opts, int popts)
struct pfr_uktable *ukt;
unsigned long maxcount;
size_t s = sizeof(maxcount);
int error;
bzero(&ab, sizeof(ab));
ab.pfrb_type = PFRB_ADDRS;
@@ -5982,8 +5983,8 @@ process_tabledef(char *name, struct table_opts *opts, int popts)
} else
ukt = NULL;
if (!(pf->opts & PF_OPT_NOACTION) &&
pfctl_define_table(name, opts->flags, opts->init_addr,
pf->anchor->path, &ab, pf->anchor->ruleset.tticket, ukt)) {
(error = pfctl_define_table(name, opts->flags, opts->init_addr,
pf->anchor->path, &ab, pf->anchor->ruleset.tticket, ukt)) != 0) {
if (sysctlbyname("net.pf.request_maxcount", &maxcount, &s,
NULL, 0) == -1)
@@ -5995,7 +5996,7 @@ process_tabledef(char *name, struct table_opts *opts, int popts)
name);
else
yyerror("cannot define table %s: %s", name,
pf_strerror(errno));
pf_strerror(error));
goto _error;
}
+1 -1
View File
@@ -2476,7 +2476,7 @@ pfctl_load_tables(struct pfctl *pf, char *path, struct pfctl_anchor *a,
pf->anchor->ruleset.tticket,
ukt->pfrukt_init_addr ? PFR_FLAG_ADDRSTOO : 0);
if (e != 0)
err(1, "%s pfctl_ina_define() %s@%s", __func__,
errc(1, e, "%s pfctl_ina_define() %s@%s", __func__,
kt->pfrkt_name, kt->pfrkt_anchor);
RB_REMOVE(pfr_ktablehead, &pfr_ktables, kt);
pfr_buf_clear(&ukt->pfrukt_addrs);