Revert "pf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex"

This commit is correct, but was misattributed. Revert so we can re-apply
with the correct author set.

This reverts commit 6d4a140acf.
This commit is contained in:
Kristof Provost 2024-02-06 17:22:59 +01:00
parent 7572fe89ad
commit 8a16fd431d

View file

@ -413,22 +413,25 @@ VNET_DEFINE(struct pf_limit, pf_limits[PF_LIMIT_MAX]);
} while (0)
static struct pfi_kkif *
BOUND_IFACE(struct pf_kstate *st, struct pfi_kkif *k)
BOUND_IFACE(struct pf_krule *r, struct pfi_kkif *k, struct pf_pdesc *pd)
{
/* Floating unless otherwise specified. */
if (! (st->rule.ptr->rule_flag & PFRULE_IFBOUND))
if (! (r->rule_flag & PFRULE_IFBOUND))
return (V_pfi_all);
/* Don't overrule the interface for states created on incoming packets. */
if (st->direction == PF_IN)
if (pd->dir == PF_IN)
return (k);
/* No route-to, so don't overrule. */
if (st->rt != PF_ROUTETO)
/* No route-to, so don't overrrule. */
if (r->rt != PF_ROUTETO)
return (k);
if (r->rpool.cur == NULL)
return (k);
/* Bind to the route-to interface. */
return (st->rt_kif);
return (r->rpool.cur->kif);
}
#define STATE_INC_COUNTERS(s) \
@ -5015,7 +5018,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a,
__func__, nr, sk, nk));
/* Swap sk/nk for PF_OUT. */
if (pf_state_insert(BOUND_IFACE(s, kif), kif,
if (pf_state_insert(BOUND_IFACE(r, kif, pd), kif,
(pd->dir == PF_IN) ? sk : nk,
(pd->dir == PF_IN) ? nk : sk, s)) {
REASON_SET(&reason, PFRES_STATEINS);