Page MenuHomeFreeBSD

pf: Check if source nodes use a valid redirection address
ClosedPublic

Authored by vegeta_tuxpowered.net on Oct 21 2025, 8:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 27, 10:30 PM
Unknown Object (File)
Tue, Nov 25, 11:34 PM
Unknown Object (File)
Tue, Nov 18, 1:39 PM
Unknown Object (File)
Tue, Nov 18, 5:11 AM
Unknown Object (File)
Sat, Nov 15, 10:14 PM
Unknown Object (File)
Thu, Nov 13, 7:37 PM
Unknown Object (File)
Tue, Nov 4, 12:58 PM
Unknown Object (File)
Mon, Nov 3, 2:24 AM

Details

Summary

Source nodes redirect (nat-to, rdr-to, route-to) all further connections
matching the rule which has created the source node. The source node is
valid as long as there are states resulting from the rule or until the
source node lifetime expires. When the rule's redirection pool is
modified (e.g. table contents are changed) the source node is still
valid and it will redirect new connections to invalid target (e.g. a
dead next-hop).

When performing source tracking after finding a source node check if the
redirection address still exists in pool of the rule which has created
this node. If not, delete the source node. This will result in finding a
new redirection address and creation of a new source node.

Obtained from: OpenBSD
Sponsored by: InnoGames GmbH

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/netpfil/pf/pf_lb.c
586

The test I wrote only tests the case for PF_ADDR_TABLE because that can easily be modified with pfctl without changing the ruleset (which would invalidate all SNs). Any idea how I can modify the redirection pool of an existing rule for other cases? The logic here is copied from OpenBSD with addition of comments and redirection AF.

Do you have a specific OpenBSD patch you obtained this from?

sys/netpfil/pf/pf_lb.c
586

We can probably do PF_ADDR_DYNIFTL and change the addresses assigned to that interface. I don't think we can for the other cases.

Testing them all would be good, obviously, but just having one scenario that exercises this code path already gets us 80-90% of the utility of the test case, so I wouldn't worry too much about it.

This revision is now accepted and ready to land.Oct 29 2025, 10:58 AM