git: 8a16fd431d83 - main - Revert "pf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 Feb 2024 16:25:26 UTC
The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=8a16fd431d832f4601000f927701612c5d6e0a41 commit 8a16fd431d832f4601000f927701612c5d6e0a41 Author: Kristof Provost <kp@FreeBSD.org> AuthorDate: 2024-02-06 16:22:59 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2024-02-06 16:22:59 +0000 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 6d4a140acfdf637bb559d371c583e4db478e1549. --- sys/netpfil/pf/pf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 12b72f50aa02..9f2c07c614b3 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -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 overrrule. */ + if (r->rt != PF_ROUTETO) return (k); - /* No route-to, so don't overrule. */ - if (st->rt != PF_ROUTETO) + 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);