The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=3171a60de403b9088b870d38377039ab9718b7db
commit 3171a60de403b9088b870d38377039ab9718b7db Author: R. Christian McDonald <[email protected]> AuthorDate: 2026-09-30 21:58:19 +0000 Commit: R. Christian McDonald <[email protected]> CommitDate: 2026-09-30 22:02:46 +0000 pfctl: print "pass" on nat/rdr/binat rules again c2d03a920ec7 rewrote the action printing in print_rule() from OpenBSD, which has no natpass, and dropped the "pass" keyword. A ruleset loaded from "pfctl -sn" output therefore lost its nat-pass semantics. Add a parser test covering nat, rdr, rdr log and binat with pass. Reviewed by: kp Approved by: kp (mentor) Fixes: c2d03a920ec7 ("pfctl: fix anchortypes bounds test") MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D60183 --- sbin/pfctl/pfctl_parser.c | 5 ++++- sbin/pfctl/tests/files/pf1080.in | 5 +++++ sbin/pfctl/tests/files/pf1080.ok | 5 +++++ sbin/pfctl/tests/pfctl_test_list.inc | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index c6ad62555b86..46e8f81d0693 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -919,8 +919,11 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int opts, int numeric) } else { if (r->action >= nitems(actiontypes)) printf("action(%d)", r->action); - else + else { printf("%s", actiontypes[r->action]); + if (r->natpass) + printf(" pass"); + } } if (r->action == PF_DROP) { if (r->rule_flag & PFRULE_RETURN) diff --git a/sbin/pfctl/tests/files/pf1080.in b/sbin/pfctl/tests/files/pf1080.in new file mode 100644 index 000000000000..d0316a1cd6cb --- /dev/null +++ b/sbin/pfctl/tests/files/pf1080.in @@ -0,0 +1,5 @@ +nat pass on em0 from 192.0.2.0/24 to any -> 198.51.100.1 +rdr pass on em0 proto tcp from any to 198.51.100.1 port 80 -> 192.0.2.10 +rdr pass log on em0 proto tcp from any to 198.51.100.1 port 443 -> 192.0.2.10 +binat pass on em0 from 192.0.2.20 to any -> 198.51.100.20 +rdr on em0 proto tcp from any to 198.51.100.1 port 22 -> 192.0.2.10 diff --git a/sbin/pfctl/tests/files/pf1080.ok b/sbin/pfctl/tests/files/pf1080.ok new file mode 100644 index 000000000000..f2e61a691563 --- /dev/null +++ b/sbin/pfctl/tests/files/pf1080.ok @@ -0,0 +1,5 @@ +nat pass on em0 inet from 192.0.2.0/24 to any -> 198.51.100.1 +rdr pass on em0 inet proto tcp from any to 198.51.100.1 port = http -> 192.0.2.10 +rdr pass log on em0 inet proto tcp from any to 198.51.100.1 port = https -> 192.0.2.10 +rdr on em0 inet proto tcp from any to 198.51.100.1 port = ssh -> 192.0.2.10 +binat pass on em0 inet from 192.0.2.20 to any -> 198.51.100.20 diff --git a/sbin/pfctl/tests/pfctl_test_list.inc b/sbin/pfctl/tests/pfctl_test_list.inc index a2c64dfc0020..1c0251543147 100644 --- a/sbin/pfctl/tests/pfctl_test_list.inc +++ b/sbin/pfctl/tests/pfctl_test_list.inc @@ -188,3 +188,4 @@ PFCTL_TEST(1076, "State limiter") PFCTL_TEST(1077, "Source limiter") PFCTL_TEST(1078, "New page") PFCTL_TEST(1079, "rdr-to and nat-to") +PFCTL_TEST(1080, "nat/rdr/binat pass")
