Page MenuHomeFreeBSD

pf: Make nat-to and rdr-to work properly both on in and out rules
ClosedPublic

Authored by vegeta_tuxpowered.net on Mon, Oct 20, 2:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 4, 6:50 PM
Unknown Object (File)
Sat, Nov 1, 4:07 PM
Unknown Object (File)
Thu, Oct 30, 3:17 AM
Unknown Object (File)
Wed, Oct 29, 10:47 AM
Unknown Object (File)
Sat, Oct 25, 4:34 PM
Unknown Object (File)
Sat, Oct 25, 4:34 PM
Unknown Object (File)
Sat, Oct 25, 4:34 PM
Unknown Object (File)
Sat, Oct 25, 10:09 AM

Details

Summary

New-style address translation is done by nat-to and rdr-to actions on
normal match and pass rules. Those rules, when used without address
translation, can be specified without direction. But that allows users
to specify pre-routing nat and post-routing rdr. This case is not
handled properly and causes pre-routing nat to modify destination
address, as if it was a rdr rule, and post-routing rdr to modify source
address, as if it was a nat rule.

Ensure that nat-to action modifies source address and rdr-to destination
address no matter in which direction the rule is applied. The man page
for pf.conf already specifies that nat-to and rdr-to rules should be
limited to respective directions.

PR: 288577
MFC after: 3 days
Sponsored by: InnoGames GmbH

Diff Detail

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

Event Timeline

vegeta_tuxpowered.net edited the summary of this revision. (Show Details)
tests/sys/netpfil/pf/nat.sh
921

I'm unsure if we really need this test case. I have originally developed it when working on kernel side fix to ensure that NAT is properly applied on source address no matter on which direction the rule matters. But with pfctl forbidding loading such rules it can't be tested anymore. But the kernel code will accept such rule and handle it properly. Please advise :)

tests/sys/netpfil/pf/nat.sh
921

Please disregard this comment. Apparently OpenBSD does support nat-to and rdr-to on both directions and clearly states that in man pf.conf. I will rework this patch.

vegeta_tuxpowered.net retitled this revision from pf: Forbid nat-to on in rules and rdr-to on out rules to pf: Make nat-to and rdr-to work properly both on in and out rules.
vegeta_tuxpowered.net edited the summary of this revision. (Show Details)

Don't forbid address translation on non-usual direction, since OpenBSD allows it too. Enable the test for nat-to on inbound direction.

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