HomeFreeBSD

pf: Make pf_get_translation() more expressive

Description

pf: Make pf_get_translation() more expressive

Currently pf_get_translation() returns a pointer to a matching
nat/rdr/binat rule, or NULL if no rule was matched or an error occurred
while applying the translation. That is, we don't distinguish between
errors and the lack of a matching rule. This, if an error (e.g., a
memory allocation failure or a state conflict) occurs, we simply handle
the packet as if no translation rule was present. This is not
desireable.

Make pf_get_translation() return the matching rule as an out-param and
instead return a reason code which indicates whether there was no
translation rule, or there was a translation rule and we failed to apply
it, or there was a translation rule and we applied it successfully.

Reviewed by: kp, allanjude
MFC after: 3 months
Sponsored by: Klara, Inc.
Sponsored by: Modirum
Differential Revision: https://reviews.freebsd.org/D45672

Details

Provenance
markjAuthored on Aug 19 2024, 2:14 PM
Reviewer
kp
Differential Revision
D45672: pf: Make pf_get_translation() more expressive
Parents
rG9897a66923a3: pf: Let rdr rules modify the src port if doing so would avoid a conflict
Branches
Unknown
Tags
Unknown