History log of /netbsd-current/usr.sbin/npf/npfctl/npf_build.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.56 18-Aug-2023 tnn

npfctl: adapt to new libpcap API


Revision tags: netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.55 30-May-2020 rmind

Major NPF improvements (merge from upstream):

- Switch to the C11-style atomic primitives using atomic_loadstore(9).

- npfkern: introduce the 'state.key.interface' and 'state.key.direction'
settings. Users can now choose whether the connection state should be
strictly per-interface or global at the configuration level. Keep NAT
logic to be always per-interface, though.

- npfkern: rewrite the G/C worker logic and make it self-tuning.

- npfkern and libnpf: multiple bug fixes; add param exporting; introduce
more parameters. Remove npf_nvlist_{copyin,copyout}() functions and
refactor npfctl_load_nvlist() with others; add npfctl_run_op() to have
a single entry point for operations. Introduce npf_flow_t and clean up
some code.

- npfctl: lots of fixes for the 'npfctl show' logic; make 'npfctl list'
more informative; misc usability improvements and more user-friendly
error messages.

- Amend and improve the manual pages.


# 1.54 23-May-2020 rmind

Backport selected NPF fixes from the upstream (to be pulled up):

- npf_conndb_lookup: protect the connection lookup with pserialize(9),
instead of incorrectly assuming that the handler always runs at IPL_SOFNET.
Should fix crashes reported on high load (PR/55182).

- npf_config_destroy: handle partially initialized config; fixes crashes
with some invalid configurations.

- NAT policy creation / destruction: set the initial reference and do not
wait for reference draining on destruction; destroy the policy on the
last reference drop instead. Fixes a lockup with the dynamic NAT rules.

- npf_nat_{export,import}: fix a regression since dynamic NAT rules.

- npfctl: fix a regression and restore the default group behaviour.

- Add npf_cache_tcp() and validate the TCP data offset (from maxv@).


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.53 30-Sep-2019 rmind

libnpf/npfctl: support dynamic NAT rulesets using a name prefix.


# 1.52 29-Sep-2019 rmind

npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.

(missed a file in previous commit; cvs is so helpful..)


# 1.51 08-Aug-2019 rmind

NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.


Revision tags: netbsd-9-base
# 1.50 25-Jul-2019 rmind

branches: 1.50.2;
npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.55 30-May-2020 rmind

Major NPF improvements (merge from upstream):

- Switch to the C11-style atomic primitives using atomic_loadstore(9).

- npfkern: introduce the 'state.key.interface' and 'state.key.direction'
settings. Users can now choose whether the connection state should be
strictly per-interface or global at the configuration level. Keep NAT
logic to be always per-interface, though.

- npfkern: rewrite the G/C worker logic and make it self-tuning.

- npfkern and libnpf: multiple bug fixes; add param exporting; introduce
more parameters. Remove npf_nvlist_{copyin,copyout}() functions and
refactor npfctl_load_nvlist() with others; add npfctl_run_op() to have
a single entry point for operations. Introduce npf_flow_t and clean up
some code.

- npfctl: lots of fixes for the 'npfctl show' logic; make 'npfctl list'
more informative; misc usability improvements and more user-friendly
error messages.

- Amend and improve the manual pages.


# 1.54 23-May-2020 rmind

Backport selected NPF fixes from the upstream (to be pulled up):

- npf_conndb_lookup: protect the connection lookup with pserialize(9),
instead of incorrectly assuming that the handler always runs at IPL_SOFNET.
Should fix crashes reported on high load (PR/55182).

- npf_config_destroy: handle partially initialized config; fixes crashes
with some invalid configurations.

- NAT policy creation / destruction: set the initial reference and do not
wait for reference draining on destruction; destroy the policy on the
last reference drop instead. Fixes a lockup with the dynamic NAT rules.

- npf_nat_{export,import}: fix a regression since dynamic NAT rules.

- npfctl: fix a regression and restore the default group behaviour.

- Add npf_cache_tcp() and validate the TCP data offset (from maxv@).


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.53 30-Sep-2019 rmind

libnpf/npfctl: support dynamic NAT rulesets using a name prefix.


# 1.52 29-Sep-2019 rmind

npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.

(missed a file in previous commit; cvs is so helpful..)


# 1.51 08-Aug-2019 rmind

NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.


Revision tags: netbsd-9-base
# 1.50 25-Jul-2019 rmind

branches: 1.50.2;
npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.54 23-May-2020 rmind

Backport selected NPF fixes from the upstream (to be pulled up):

- npf_conndb_lookup: protect the connection lookup with pserialize(9),
instead of incorrectly assuming that the handler always runs at IPL_SOFNET.
Should fix crashes reported on high load (PR/55182).

- npf_config_destroy: handle partially initialized config; fixes crashes
with some invalid configurations.

- NAT policy creation / destruction: set the initial reference and do not
wait for reference draining on destruction; destroy the policy on the
last reference drop instead. Fixes a lockup with the dynamic NAT rules.

- npf_nat_{export,import}: fix a regression since dynamic NAT rules.

- npfctl: fix a regression and restore the default group behaviour.

- Add npf_cache_tcp() and validate the TCP data offset (from maxv@).


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
# 1.53 30-Sep-2019 rmind

libnpf/npfctl: support dynamic NAT rulesets using a name prefix.


# 1.52 29-Sep-2019 rmind

npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.

(missed a file in previous commit; cvs is so helpful..)


# 1.51 08-Aug-2019 rmind

NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.


Revision tags: netbsd-9-base
# 1.50 25-Jul-2019 rmind

branches: 1.50.2;
npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.53 30-Sep-2019 rmind

libnpf/npfctl: support dynamic NAT rulesets using a name prefix.


# 1.52 29-Sep-2019 rmind

npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.

(missed a file in previous commit; cvs is so helpful..)


# 1.51 08-Aug-2019 rmind

NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.


Revision tags: netbsd-9-base
# 1.50 25-Jul-2019 rmind

branches: 1.50.2;
npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.51 08-Aug-2019 rmind

NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.


Revision tags: netbsd-9-base
# 1.50 25-Jul-2019 rmind

branches: 1.50.2;
npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.50 25-Jul-2019 rmind

npfctl: fix the bpf.jit parameter handling.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.49 23-Jul-2019 rmind

NPF improvements:
- Add support for dynamic NETMAP algorithm (stateful net-to-net).
- Add most of the support for the dynamic NAT rules; a little bit more
userland work is needed to finish this up and enable.
- Replace 'stateful-ends' with more permissive 'stateful-all'.
- Add various tunable parameters and document them, see npf-params(7).
- Reduce the memory usage of the connection state table (conndb).
- Portmap rewrite: use memory more efficiently, handle addresses dynamically.
- Bug fix: add splsoftnet()/splx() around the thmap writers and comment.
- npftest: clean up and simplify; fix some memleaks to make ASAN happy.


Revision tags: phil-wifi-20190609
# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2; 1.45.4;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.48 17-Apr-2019 tih

Summary: Ensure default TCP flags are applied to rules like 'pass stateful all'

The documented default "flags S/SAFR" for stateful rules that affect
TCP packets but don't specify any flags, doesn't actually get applied
to a rule like "pass stateful out all". The big problem with this is
that when you then do a "block return-rst" for an incoming packet, the
generated RST packet will create state for the connection attempt it's
blocking, so that a second attempt from the same source will pass.

This change makes the default flags actually apply to such simple
rules. It also fixes a related bug in the code generation for the
flag matching, where part of the action could erroneously be omitted.

Reviewed by <rmind>
Closes PR bin/54124
Pullup to NetBSD 8


Revision tags: pgoyette-compat-20190127
# 1.47 19-Jan-2019 rmind

Major NPF improvements:
- Convert NPF connection table to thmap. State lookup is now lock-free.
- Improve connection state G/C: it is now incremental and tunable.
- Add support for dynamic NAT address. Translation addresses can now be
selected from a pool of addresses. There are two selection algorithms,
"ip-hash" and "round-robin" (see the man page).
- Translation address can be specified as e.g. ifaddrs(wm0) in npf.conf
to dynamically choose an IP from the interface address(es).
- Add support for the NETMAP algorithm with static NAT for net-to-net
translation (it is equivalent to iptables NETMAP logic).
- Convert 'ipset' tables to use thmap; the table lookup is now lock-free.
- Misc improvements, bug fixes and more unit tests.
- Bump NPF_VERSION (will also bump libnpf).


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.46 29-Sep-2018 rmind

NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.45 10-Dec-2017 rmind

branches: 1.45.2;
npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

branches: 1.44.4;
npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.45 10-Dec-2017 rmind

npfctl: add support for the 'no-ports' flag in the 'map' statements.
This allows us to create a NAT policy without the port translation.


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.44 19-Jan-2017 rmind

npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

branches: 1.43.2;
npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.44 19-Jan-2017 rmind

npfctl:
- Add protocol filter option for "map".
- Print user-friendly error if table contains an entry with invalid netmask.
- Add support for inline ports.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


Revision tags: pgoyette-localcount-20170107
# 1.43 03-Jan-2017 rmind

npfctl: dynamic interface address handling; update npf.conf(8).


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

branches: 1.40.2;
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.


# 1.42 27-Dec-2016 rmind

npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


# 1.41 26-Dec-2016 christos

Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.40 08-Jun-2015 rmind

- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.


# 1.39 21-Mar-2015 rmind

npfctl:
- Fix the filter criteria when to/from is omitted but port used.
- Print more user-friendly error if an NPF table has a duplicate entry.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.38 31-May-2014 rmind

branches: 1.38.2;
npfctl_build_code: generate TCP/UDP check for ports case when other blocks
do not imply L4 check; add an assert in npfctl_bpf_proto() and elsewhere.


# 1.37 15-May-2014 rmind

NPF: imply SYN-only check for the stateful rules by default (when inspecting
TCP packets). Many users trip here. This behaviour can be overriden with the
explicit "flags" keyword, but other configuration does not really make sense.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.36 13-Feb-2014 rmind

branches: 1.36.2;
NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296. Add a unit test. Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!


# 1.35 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


# 1.34 06-Feb-2014 christos

fix vax build.


# 1.33 06-Feb-2014 rmind

Add support for CDB based NPF tables.


# 1.32 03-Feb-2014 rmind

- npfctl: fix table IDs (breakage since the table naming was added).
- libnpf: remove npf_table_exists_p() from public API.


# 1.31 22-Nov-2013 rmind

Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now. Also, fix table name checking in npfctl.


# 1.30 19-Nov-2013 rmind

Simplify parsing of npf.conf elements, create the npfvar_t when a value is
parsed (to be used as a general structured for variables and inlined values),
few misc improvements.


# 1.29 12-Nov-2013 rmind

NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes. Bump NPF_VERSION.


# 1.28 08-Nov-2013 rmind

NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections). Once the interface is reattached they will
become active.

Bump NPF_VERSION.


# 1.27 20-Sep-2013 rmind

- NPF: change the group/ruleset syntax - simplify. Update npf.conf(5) manual.
- Add support for the inline pcap-filter(7) syntax in the rule, e.g.:
block out final pcap-filter "tcp and dst 10.1.1.252"


# 1.26 19-Sep-2013 rmind

npfctl: remove some n-code leftovers, fix the build, update the man pages.


# 1.25 19-Sep-2013 rmind

- Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.24 19-May-2013 rmind

- Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.


Revision tags: agc-symver-base
# 1.23 20-Mar-2013 christos

Make ALG's autoloadable by providing in the config file:
alg "algname"


# 1.22 18-Mar-2013 rmind

- Extend npf.conf syntax to support dynamic NAT policies.
- Imply dynamic group when using "ruleset" keyword.


# 1.21 16-Feb-2013 rmind

- Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs. Also, update the man page.


# 1.20 11-Feb-2013 rmind

Allow filtering on IP addresses even if the L4 protocol is unknown.
Patch from spz@.


# 1.19 10-Feb-2013 rmind

- Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.


# 1.18 09-Feb-2013 rmind

NPF:
- Implement dynamic NPF rules. Controlled through npf(3) library of via
npfctl rule command. A rule can be removed using a unique identifier,
returned on addition, or using a key which is SHA1 hash of the rule.
Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.


Revision tags: yamt-pagecache-base8
# 1.17 23-Dec-2012 rmind

- Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages. Misc.


Revision tags: yamt-pagecache-base7
# 1.16 10-Dec-2012 rmind

npfctl: add 'validate' command to check the config, but not load it. Update
the man page. Also add a small note about 'debug' command, PR/47298.


# 1.15 26-Nov-2012 rmind

npfctl: extend syntax for extracting interface IP address(es) by the family.


Revision tags: yamt-pagecache-base6
# 1.14 16-Sep-2012 rmind

Implement dynamic NPF extensions interface. An extension consists of
dynamically loaded module (.so) supplementing npfctl(8) and a kernel
module. Move normalisation and logging functionality into their own
extensions. More improvements to come.


# 1.13 12-Aug-2012 rmind

branches: 1.13.2;
- Extend npftest: add ruleset inspection testing from the config generated
by npfctl debug functionality. Auto-create npftest interfaces for this.
- NPF sessions: combine protocol and interface into a separate substructure,
share between the entries and thus fix the handling of them. Constify.
- npftest: add regression tests for NAT policies.
- npf_build_nat: simplify and fix bi-NAT regression.
- Bump yacc stack size for npfctl.


# 1.12 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


# 1.11 15-Jul-2012 rmind

- Rework NPF tables and fix support for IPv6. Implement tree table type
using radix / Patricia tree. Universal IPv4/IPv6 comparator for ptree(3)
was contributed by Matt Thomas.
- NPF tables: update regression tests, improve npfctl(8) error messages.
- Fix few bugs when using kernel modules and handle module autounloader.
- Few other fixes and misc cleanups.
- Bump the version.


# 1.10 01-Jul-2012 rmind

NPF improvements:
- Add NPF_OPCODE_PROTO to match the address and/or protocol only.
- Update parser to support arbitrary "pass proto <name/number>".
- Fix IPv6 address and protocol handling (add a regression test).
- Fix few theorethical races in session handling module.
- Misc fixes, simplifications and some clean up.


# 1.9 16-Jun-2012 christos

remove error(1) output


# 1.8 16-Jun-2012 christos

make this compile again.


# 1.7 15-Jun-2012 rmind

- Rework NPF NAT syntax to be more structured and support future additions
of different types and configurations of NAT.
- npfctl: improve disassemble and show-config command functionality.
- Fix custom ICMP code and type filtering.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.6 26-Feb-2012 christos

branches: 1.6.2;
- make each element of a variable hold a type
- change get_type to take an index, so we can get the individual types of
each element (since primitive elements can be in lists)
- make port_range primitive
- add a routine to convert a variable of primitives to a variable containing
- only port ranges.


# 1.5 20-Feb-2012 rmind

- Add NPF_DECISION_BLOCK and NPF_DECISION_PASS. Be more defensive in the
packet handler. Change the default policy to block when the config is
loaded and set it to pass when flush operation is performed.
- Use kmem_zalloc(9) instead of kmem_alloc(9) in few places.
- npf_rproc_{create,release}: use kmem_intr_{alloc,free} as the destruction
of rule procedure might happen in the interrupt handler (under a very rare
condition, if config reload races with the handler).
- npf_session_establish: check whether layer 3 and 4 are cached.
- npfctl_build_group: do not make groups as passing rules.
- Remove some unecessary header inclusion.


Revision tags: netbsd-6-base
# 1.4 06-Feb-2012 rmind

branches: 1.4.2;
- Handle NPF rule procedures in the parser and thus re-enable them.
- Few small updates to the man page.


# 1.3 05-Feb-2012 rmind

Multiple NPF fixes, add better error reporting from kernel side, add some
asserts, bump the version.


# 1.2 15-Jan-2012 rmind

- Expire all sessions on flush.
- Enable checking for zero mask in IP{4,6}MATCH after npfctl changes.
- Make locking symmetric for npf_ruleset_inspect().
- Sync function prototypes in npf(3) man page with reality.
- Rename NPF_TABLE_RBTREE to NPF_TABLE_TREE.


# 1.1 08-Jan-2012 rmind

Full rewrite of npfctl(8) parser and rework of n-code generation part.
Fixes most of the known bugs and issues with the utility. Note: rule
procedures are not yet (as we want to make them fully modular).

Huge thanks to Martin Husemann who wrote the parser and Christos Zoulas
who wrote intermediate structures and helped to complete the work.