freebsd-dev/sys/netpfil/pf
Kristof Provost 829a69db85 pf: change pf_route so pf only runs when packets enter and leave the stack.
before this change pf_route operated on the semantic that pf runs
when packets go over an interface, so when pf_route changed which
interface the packet was on it would run pf_test again. this change
changes (restores) the semantic that pf is only supposed to run
when packets go in or out of the network stack, even if route-to
is responsibly for short circuiting past the network stack.

just to be clear, for normal packets (ie, those not touched by
route-to/reply-to/dup-to), there isn't a difference between running
pf when packets enter or leave the stack, or having pf run when a
packet goes over an interface.

the main reason for this change is that running the same packet
through pf multiple times creates confusion for the state table.
by default, pf states are floating, meaning that packets are matched
to states regardless of which interface they're going over. if a
packet leaving on em0 is rerouted out em1, both traversals will end
up using the same state, which at best will make the accounting
look weird, or at worst fail some checks in the state and get
dropped.

another reason for this commit is is to make handling of the changes
that route-to makes consistent with other changes that are made to
packet. eg, when nat is applied to a packet, we don't run pf_test
again with the new addresses.

the main caveat with this diff is you can't have one rule that
pushes a packet out a different interface, and then have a rule on
that second interface that NATs the packet. i'm not convinced this
ever worked reliably or was used much anyway, so we don't think
it's a big concern.

discussed with many, with special thanks to bluhm@, sashan@ and
sthen@ for weathering most of that pain.
ok claudio@ sashan@ jmatthew@

Obtained from:	OpenBSD
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29554
2021-04-05 09:57:06 +02:00
..
if_pflog.c pf: Split pfi_kif into a user and kernel space structure 2021-01-05 23:35:37 +01:00
if_pfsync.c pfsync: Unconditionally push packets when requesting state updates 2021-03-17 19:18:14 +01:00
in4_cksum.c SPDX: license IDs for some ISC-related files. 2017-12-08 15:57:29 +00:00
pf_altq.h Extended pf(4) ioctl interface and pfctl(8) to allow bandwidths of 2018-08-22 19:38:48 +00:00
pf_if.c pf: Simplify cleanup 2021-03-12 12:12:35 +01:00
pf_ioctl.c pf: pool/kpool conversion code 2021-03-16 10:30:28 +01:00
pf_lb.c pf: Split pfi_kif into a user and kernel space structure 2021-01-05 23:35:37 +01:00
pf_mtag.h pf: duplicate frames only once when using dup-to pf rule 2021-01-28 16:46:44 +01:00
pf_norm.c pf: Fix incorrect fragment handling 2021-02-25 21:51:08 +01:00
pf_osfp.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
pf_ruleset.c pf: quiet debugging printfs 2021-01-11 22:30:44 +01:00
pf_table.c pf: Split pf_rule into kernel and user space versions 2021-01-05 23:35:36 +01:00
pf.c pf: change pf_route so pf only runs when packets enter and leave the stack. 2021-04-05 09:57:06 +02:00
pf.h pf: Split pfi_kif into a user and kernel space structure 2021-01-05 23:35:37 +01:00