FreeBSD/src aeddee8sbin/pfctl parse.y pfctl.c, sbin/pfctl/tests pfctl_test.c pfctl_test_list.inc

pfctl: Split pool parsing into separate functions

The pf pools are used in NAT, route-to and af-to rules. Some parts of
code are duplicated between them. Create functions apply_redirspec(),
apply_nat_ports() and apply_rdr_ports() to handle the common tasks.

Simplify data structures used for pool parsing. Move the contents of
struct redirection to struct redirspec. Map all ways of parsing pools
directly onto struct redirspec. Name various forms of struct redirspect
to hint where they are used.

Remove struct redirspec *rroute from struct filter_opts, because
filter_opts is bzero()'ed after the route part of rule is parsed, and
thus can't be used.

Add tests to ensure that parsing and error messages behave as expected.
The tests have been written and tested with pfctl from before this
patch.


    [6 lines not shown]
DeltaFile
+260-309sbin/pfctl/parse.y
+162-32sbin/pfctl/tests/pfctl_test.c
+37-0sbin/pfctl/tests/pfctl_test_list.inc
+10-0sbin/pfctl/pfctl.c
+3-0sbin/pfctl/tests/files/pf1054.in
+1-1sbin/pfctl/tests/files/pf1026.ok
+473-34277 files not shown
+550-34483 files

FreeBSD/src 7a372bdsbin/pfctl parse.y pfctl_parser.c, sbin/pfctl/tests/files pf1027.ok pf1027.in

pf: make reply-to work with nat64

Just like route-to reply-to is problematic when used in combination with nat64.

In the normal (i.e. without nat64) flow we return immediately from pf_route().
However, with nat64 we need to continue and do a route lookup. In that case
we should not make the extra pf_test(PF_OUT) call to remain similar to the
non-nat64 flow.

We also have to fix the interface binding. We can only bind to the interface
after we've done the route lookup, not before.

Add a funcional test case, and a test for pfctl's rule printing.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+54-34sys/netpfil/pf/pf.c
+45-0tests/sys/netpfil/pf/nat64.sh
+2-2sbin/pfctl/parse.y
+2-1sbin/pfctl/pfctl_parser.c
+1-0sbin/pfctl/tests/files/pf1027.ok
+1-0sbin/pfctl/tests/files/pf1027.in
+105-371 files not shown
+106-377 files