History log of /src/usr.sbin/npf/npfctl/
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.16 14-Sep-2023 rillig

npfctl: remove no-op NOLINT definition

Setting NOLINT must be done before including <bsd.own.mk> to have an
effect.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.15 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.14 24-Aug-2019 rmind

libnpf fix: link the library itself to libnv; libnpf users should not be
expected to assume this dependency.


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
1.13 29-Sep-2018 rmind

branches: 1.13.2;
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: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base 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 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.12 29-Jun-2016 christos

branches: 1.12.14; 1.12.16;
remove libcrypto dependency, fix other dependencies.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.11 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 agc-symver-base
1.10 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 yamt-pagecache-base7
1.9 01-Nov-2012 christos

put in /sbin


Revision tags: yamt-pagecache-base6
1.8 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.7 30-May-2012 rmind

branches: 1.7.2;
npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
1.6 10-Mar-2012 christos

Add a small disassembler.


Revision tags: netbsd-6-base
1.5 08-Jan-2012 rmind

branches: 1.5.2;
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: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.4 04-Feb-2011 rmind

branches: 1.4.4;
Fix sun2 builds. Noted by joerg@.


1.3 02-Feb-2011 rmind

NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


Revision tags: matt-mips64-premerge-20101231
1.2 24-Aug-2010 rmind

branches: 1.2.2;
Move npf.conf(5-8) into the correct section, hence npf.conf(5).


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.98 02-Jul-2025 gutteridge

npf.conf.5: various grammar, spelling, formatting tweaks


1.97 02-Jul-2025 joe

Layer 2 filtering man


1.96 02-Jun-2025 kre

One line, one sentence.


1.95 02-Jun-2025 gutteridge

npf.conf.5: bump date to reflect recent material changes


1.94 02-Jun-2025 gutteridge

npf.conf.5: minor style consistency tweaks


1.93 01-Jun-2025 joe

user/group filtering manuel


1.92 20-Mar-2025 christos

PR/58116: Attaulah: Allow comments inside lists in npf.conf


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.91 30-May-2020 rmind

branches: 1.91.8;
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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.90 30-Sep-2019 uwe

Use -width Pa for FILES.


1.89 30-Sep-2019 rmind

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


Revision tags: netbsd-9-base
1.88 23-Jul-2019 wiz

branches: 1.88.2;
New sentence, new line. Avoid formatting punctuation. Remove superfluous Pp.


1.87 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.86 08-Apr-2019 wiz

Improve wording.


1.85 07-Apr-2019 rmind

npf.conf(5): Add more info about ifaddrs().


Revision tags: pgoyette-compat-20190127
1.84 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
1.83 08-Jan-2019 uwe

Actually, according to the grammar the square brackets in the "tcp
flags" are not literal, so use .Op to show that /mask is optional.


1.82 08-Jan-2019 uwe

Restore macro with effect. Fix the real problem that prevented it to
have the effect.


1.81 08-Jan-2019 wiz

New sentence, new line. Punctuation fixes. Remove macros without effect.


1.80 08-Jan-2019 gutteridge

npf.conf(5): add a minor clarification about table types that can't
accept masks on IP addresses. Prompted by Rob Hunter in PR bin/51900.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
1.79 21-Sep-2018 uwe

According to the grammar and examples the static table is defined with
"file" keyword, not "static".


1.78 21-Sep-2018 uwe

Improve markup.


1.77 21-Sep-2018 maxv

Wrap long lines, so that nothing overflows.


1.76 19-Sep-2018 maxv

Switch back to tabs, it was nicer this way.


Revision tags: pgoyette-compat-0906
1.75 04-Sep-2018 maxv

Fix the "Interfaces" section, I understood wrong. Talk about inference,
because it was not mentioned before, and it plays an important role.
Discussed with rmind. Probably not the last pass.


1.74 02-Sep-2018 wiz

New sentence, new line. Use Fn for functions.


1.73 02-Sep-2018 maxv

Be clearer about the difference between static vs dynamic interface list,
and slightly improve wording.

My understanding is that when none of inet4/inet6/ifaddrs is passed, NPF
assumes ifaddrs.


1.72 01-Sep-2018 wiz

Remove superfluous Pp.


1.71 01-Sep-2018 rmind

npf.conf(5): fix some of the previous incorrect or inaccurate changes.
The TCP flags option is not only for the stateful tracking. Dynamic NAT
implies NAPT; algorithms, at least for now, are for static NAT mappings.
Mention that ALG ICMP is also for traceroute behind NAT; also mention
"MSS clamping" (some users might search for this term, so keeping the
terminology is helpful).


1.70 31-Aug-2018 maxv

rename net-seg -> map-seg, and document it


1.69 31-Aug-2018 maxv

"interface" already contains "var-name", so don't mention it in "filt-addr",
that's redundant


1.68 31-Aug-2018 maxv

should be port-opts


1.67 31-Aug-2018 maxv

Clarify the "Groups" section.


1.66 27-Aug-2018 wiz

Add missing -width; remove unnecessary .Pp.


1.65 27-Aug-2018 maxv

Improve the "Map" section.


1.64 27-Aug-2018 maxv

Document ALGs.


1.63 17-Aug-2018 maxv

Add the values of "algo" in the grammar, and use # as comment marker for
man-k.org (and others) not to highlight things in an incorrect way.


1.62 17-Aug-2018 maxv

Add missing quote in static-rule, it causes man-k.org (and other tools)
to wrongly highlight the grammar.


1.61 17-Aug-2018 maxv

Replace "rproc"->"proc" in the grammar (spotted by he@), and slightly
reword.


1.60 17-Aug-2018 maxv

Replace () by [] in tcp-flags.

Fix proc-opts, the value is optional, noted by he@.


1.59 16-Aug-2018 maxv

Improve wording.


1.58 16-Aug-2018 maxv

Improve the "Map" section a little.


1.57 16-Aug-2018 maxv

Document the "flags" keyword.


1.56 16-Aug-2018 maxv

Improve the "Rules" section: better explain the "final" keyword (it is
the same as PF's "quick", so use the same wording), and document the
"return" options.

While here simplify the man code, suggested by wiz.


1.55 16-Aug-2018 maxv

Add quotes around the option names, to match the actual npf conf.


1.54 16-Aug-2018 maxv

Enlighten the "Procedures" section. In particular document the "no-df"
option. Also replace "normalisation" -> "normalization", to match the
name of the rule.


1.53 13-Aug-2018 wiz

Add missing El. Remove trailing whitespace.


1.52 07-Aug-2018 sevan

First pass at editing this manual.
Add a link to the NPF documentation website and refer to it.
Switch the multiple structural elements to a list to make it easier to read and
extend.
Clarify tables, re-order so all terms are before the example.
Clarify obtaining addresses per family
Move the minimum requirement for a default group to the group section.


Revision tags: 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.51 11-Dec-2017 wiz

branches: 1.51.2; 1.51.4;
Remove superfluous Pp.


1.50 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: perseant-stdc-iso10646-base
1.49 03-Jul-2017 wiz

Remove workaround for ancient HTML generation code.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-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.48 20-Jan-2017 wiz

branches: 1.48.4;
Bump date for previous.


1.47 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.46 03-Jan-2017 rmind

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


1.45 27-Dec-2016 rmind

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


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.44 01-Feb-2015 rmind

branches: 1.44.2;
npf.conf(5): mention alg, include in the example, minor fix.


1.43 26-Dec-2014 christos

allow turning off the bpf jit loading.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
1.42 03-Aug-2014 rmind

branches: 1.42.2;
Cross-link npf(7).


1.41 15-May-2014 wiz

Wording, typo fixes.


1.40 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.39 14-Feb-2014 rmind

branches: 1.39.2;
Document NAT algorithm option in the grammar of "map".


1.38 08-Feb-2014 rmind

NPF:
- Adjust the syntax - remove "inet" keyword in favour of more explicit
"inet4" for the address family. Consistent with "inet6" for IPv6.
- Adjust and improve the man page a little bit.


1.37 06-Feb-2014 wiz

Update count. Add serial comma.


1.36 06-Feb-2014 rmind

Add support for CDB based NPF tables.


1.35 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.34 12-Nov-2013 wiz

Remove trailing whitespace.


1.33 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.32 05-Nov-2013 kefren

sync an example with the latest group syntax change


1.31 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.30 19-Sep-2013 rmind

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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
1.29 10-Mar-2013 christos

normalise -> normalize


1.28 10-Mar-2013 rmind

Fix the example (deja vu?).


1.27 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.26 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.25 06-Dec-2012 rmind

- npf.conf(5): fix of the example config.
- Mention npf_ext_log in a comment.


1.24 26-Nov-2012 rmind

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


Revision tags: yamt-pagecache-base6
1.23 30-Sep-2012 wiz

Wording, more macros.


1.22 30-Sep-2012 rmind

Add some content to the Procedures section.


1.21 30-Sep-2012 wiz

Use more markup. New sentence, new line.


1.20 30-Sep-2012 spz

Add some content to the "Rules" section.


1.19 30-Sep-2012 wiz

Whitespace fixes, remove unnecessary Pp
XXX: Subsections Rules and Procedures seem empty?


1.18 29-Sep-2012 rmind

npf.conf(5): add syntax section and a first cut describing the structural
elements. Some improvements and fixes from spz@.


1.17 28-Sep-2012 spz

re-work the description part of the man page, as discussed with rmind@


1.16 26-Sep-2012 rmind

npf.conf(5): improve and explain grammar definition.


1.15 13-Aug-2012 rmind

branches: 1.15.2;
- npfctl show: add most of the missing cases.
- Few minor improvements to NPF man pages.


1.14 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.13 27-Jun-2012 rmind

Fix and update npf.conf(5), npfctl(8) and its usage message.


1.12 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.


1.11 30-May-2012 wiz

Remove superfluous Pp


1.10 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
1.9 06-Feb-2012 rmind

branches: 1.9.2;
Fix the family option in the grammar and example.


1.8 06-Feb-2012 rmind

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


1.7 08-Jan-2012 christos

update.


1.6 29-Nov-2011 riz

Remove quotes from "hash" and "tree" in the table examples so
the example stands a chance of actually working as written. There appear
to be other problems, too.


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
1.5 22-Mar-2011 jruoho

branches: 1.5.4;
Use .Ss for non-standard subtitles in the DESCRIPTION.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
1.4 02-Feb-2011 rmind

NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


1.3 18-Jan-2011 rmind

branches: 1.3.2;
NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.2 16-Sep-2010 rmind

NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.


1.1 24-Aug-2010 rmind

Move npf.conf(5-8) into the correct section, hence npf.conf(5).


Revision tags: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 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 perseant-stdc-iso10646-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base yamt-pagecache-base9 yamt-pagecache-tag8 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 agc-symver-base tls-maxphys-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4 yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base bouyer-quota2-nbase bouyer-quota2-base
1.2 24-Aug-2010 rmind

Move npf.conf(5-8) into the correct section, hence npf.conf(5).


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.19 10-Jul-2025 joe

Add more test to layer2 filtering for variables as a set

simplify the BPF code for multiword
we have tests to cover all possible cases in layer2 filtering


1.18 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.17 30-Oct-2024 riastradh

npfctl(8): Fix compiling multiword comparisons, i.e., IPv6 addrs.

PR bin/55403: npfctl miscompiles IPv6 rules


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.16 30-May-2020 rmind

branches: 1.16.6; 1.16.8;
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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.15 25-Aug-2019 rmind

- npfctl_load_nvlist: simplify the config loading logic.
- Fix a small race condition in npf_nat_getaddr().
- Rework pserialize/EBR wrappers, make it easier to maintain.


1.14 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.13 23-Jul-2019 rmind

branches: 1.13.2;
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.12 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 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
1.11 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 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base 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 bouyer-socketcan-base pgoyette-localcount-20170107
1.10 27-Dec-2016 rmind

branches: 1.10.6; 1.10.12; 1.10.14;
npf.conf: add support for logical NOT, e.g.: pass from ! 10.0.0.1 to any


1.9 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.8 08-Jun-2015 rmind

branches: 1.8.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.


Revision tags: tls-maxphys-base netbsd-7-base tls-earlyentropy-base
1.7 29-Jun-2014 rmind

branches: 1.7.2; 1.7.4;
NPF:
- Populate the BPF external memory store with L3 information.
- Eliminate NPF_COP_L3 call and just use the data in the memstore.
- Bump NPF_VERSION.


1.6 31-May-2014 rmind

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.5 15-May-2014 rmind

branches: 1.5.2;
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.4 15-Mar-2014 rmind

branches: 1.4.2;
npfctl_bpf_cidr: another buf fix in handling IPv6 masks (bug found on ARM).


1.3 13-Feb-2014 rmind

npfctl_bpf_cidr: fix a bug in handling of smaller IPv6 masks.


1.2 05-Nov-2013 rmind

npfctl: optimise fetch_l3() to avoid unnecessary call to NPF_COP_L3.


1.1 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.


1.63 20-Aug-2025 joe

enclose NPF_VAR_ID case in braces to fix linter build


1.62 20-Aug-2025 joe

PR bin/59511

when extracting variables for filtering in NPF, allow the handler to
recursively extract all variables that might be present in the parent variable
to fully get all the filter elements present in them. this issue poses a security risk
as intruders can find their way into your machine if you intend to block them
but have their IPs in a nested variable with other IPs as well.

so this needs to be pulled up to 9, 10, 11


this fix has been reviewed by christos@ and martin@ and tests have been included.


1.61 12-Aug-2025 mlelstv

pcap rules don't pass filter options. Provide default filter opts
(layer 3 for compat with previous behaviour) to prevent npfctl from
crashing.


1.60 12-Aug-2025 joe

PR bin/59581

set layer bit in dynamic rule attributes
effectively use it when listing either layer 2 or 3 rules

This fixes it
pullup-11


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.59 01-Jul-2025 joe

branches: 1.59.2;
userland code for layer 2 filtering in NPF

reviewed by christos@


1.58 01-Jun-2025 joe

NPF copyright 2025


1.57 31-May-2025 joe

Userland: npf rule parser for user and group id


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.56 18-Aug-2023 tnn

branches: 1.56.2;
npfctl: adapt to new libpcap API


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 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.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.1 30-May-2020 rmind

branches: 1.1.2;
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.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.34 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.33 11-Jun-2025 martin

Fix open-coded npfvar_expand_number() copy to assume the same size for
NPFVAR_NUM variables.


1.32 01-Jun-2025 joe

NPF copyright 2025


1.31 31-May-2025 joe

Userland: npf rule parser for user and group id


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127
1.30 19-Jan-2019 rmind

branches: 1.30.12;
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.29 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: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base 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.28 19-Jan-2017 rmind

branches: 1.28.10; 1.28.12;
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.27 27-Dec-2016 rmind

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


1.26 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: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.25 13-Feb-2014 rmind

branches: 1.25.8;
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.24 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.23 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.22 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.21 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.20 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 agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
1.19 26-Nov-2012 rmind

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


Revision tags: yamt-pagecache-base6
1.18 12-Aug-2012 rmind

branches: 1.18.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.17 19-Jul-2012 rmind

- npfctl_print_stats: beautification a la French style.
- npfctl_icmpcode: fix the build break.


1.16 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


1.15 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.14 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.13 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.


1.12 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


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

- 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.


Revision tags: netbsd-6-base
1.10 08-Jan-2012 rmind

branches: 1.10.2;
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: yamt-pagecache-base3 yamt-pagecache-base2
1.9 05-Nov-2011 jakllsch

freeaddrinfo() only on getaddrinfo() success.


1.8 04-Nov-2011 zoltan

Add IPv6 support for NPF.


Revision tags: yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.7 02-Feb-2011 rmind

branches: 1.7.4;
NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


1.6 18-Jan-2011 rmind

branches: 1.6.2;
NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.5 18-Dec-2010 rmind

NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.


1.4 11-Nov-2010 rmind

NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
as NAT code et al, to use it. Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6. Various fixes and clean-up.


1.3 16-Sep-2010 rmind

NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.


1.2 23-Aug-2010 jnemeth

fix build failure -- correct printf sizes


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 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 perseant-stdc-iso10646-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.19 19-Sep-2013 rmind

NPF: G/C n-code in favour of BPF byte-code. Delete lots of code, mmm!


1.18 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 agc-symver-base
1.17 16-Feb-2013 rmind

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


1.16 10-Feb-2013 rmind

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


1.15 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.


1.14 01-Feb-2013 spz

IPv6 linklocal address printing cosmetics


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
1.13 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.12 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.11 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.10 29-Oct-2012 rmind

Implement NPF table listing and preservation of entries on reload.
Bump the version.


1.9 13-Aug-2012 rmind

branches: 1.9.2;
- npfctl show: add most of the missing cases.
- Few minor improvements to NPF man pages.


1.8 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


1.7 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.6 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.5 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.


1.4 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
1.3 12-Mar-2012 christos

branches: 1.3.2; 1.3.4;
don't leak the branch target array.


1.2 10-Mar-2012 christos

- better printing of type/code flags/mask
- pass the instruction start pointer, instead of subtracting 1 to account for it


1.1 10-Mar-2012 christos

Add a small disassembler.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
1.5 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: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE 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 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base tls-maxphys-base
1.4 10-Mar-2013 christos

branches: 1.4.28; 1.4.30;
modules moved to /lib


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
1.3 15-Nov-2012 rmind

branches: 1.3.2; 1.3.4;
npfctl: switch to ecalloc(3).


1.2 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.1 16-Sep-2012 rmind

branches: 1.1.2;
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.


Revision tags: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 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 perseant-stdc-iso10646-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.16 19-Sep-2013 rmind

NPF: G/C n-code in favour of BPF byte-code. Delete lots of code, mmm!


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
1.15 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.14 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.13 19-Jul-2012 spz

branches: 1.13.2;
teach npf ipv6-icmp
reviewed by rmind@


1.12 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.11 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.10 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.


1.9 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
1.8 10-Mar-2012 christos

Add a small disassembler.


Revision tags: netbsd-6-base
1.7 09-Jan-2012 rmind

branches: 1.7.2;
npfctl_ncgen_putptr: use correct format for size_t.


1.6 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: yamt-pagecache-base3 yamt-pagecache-base2
1.5 04-Nov-2011 zoltan

Add IPv6 support for NPF.


Revision tags: yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
1.4 18-Dec-2010 rmind

branches: 1.4.6;
NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.


1.3 11-Nov-2010 rmind

NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
as NAT code et al, to use it. Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6. Various fixes and clean-up.


1.2 16-Sep-2010 rmind

NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


1.59 07-Sep-2025 andvar

Fix various typos, mainly in comments.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.58 02-Jul-2025 joe

define op tokens to kill warnings


1.57 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.56 11-Jun-2025 martin

NPF variables of type NPFVAR_NUM are only ever retrieved as
uint32_t values in npfvar_expand_number(). It makes no sense
to store them as unsigned long values (sizeof(yylval.num))
internally.

Besides the code in npfvar_expand_number() did not properly retrieve
values if sizeof(unsigned long) > sizeof(uint32_t), e.g. on sparc64
it picked the wrong 4 bytes and always returned 0.

So use uint32_t to create the value, saving memory and fixing a bug.


1.55 01-Jun-2025 joe

NPF copyright 2025


1.54 31-May-2025 joe

Userland: npf rule parser for user and group id


1.53 10-Apr-2025 joe

notify us when we use undefined port variable


1.52 20-Mar-2025 christos

PR/58116: Attaulah: Allow comments inside lists in npf.conf


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.51 30-May-2020 rmind

branches: 1.51.8;
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.


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

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


Revision tags: netbsd-9-base
1.49 23-Jul-2019 rmind

branches: 1.49.2;
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 pgoyette-compat-20190127
1.48 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.47 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.46 10-Dec-2017 rmind

branches: 1.46.2; 1.46.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.


1.45 03-Dec-2017 mlelstv

allow PASS opt_proto ALL syntax in map statement.


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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 20-Jan-2017 rmind

npfctl: fix shift/reduce conflicts, thanks to riastradh@.


1.43 20-Jan-2017 kre

Add missing ; - hopefully unbreak build.


1.42 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
1.41 11-Jan-2017 christos

branches: 1.41.2;
Don't silently take the first element of multiple element variables.


Revision tags: pgoyette-localcount-20170107
1.40 03-Jan-2017 rmind

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


1.39 27-Dec-2016 rmind

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


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.38 24-Mar-2015 christos

branches: 1.38.2;
allow lists as filter addresses.


1.37 04-Jan-2015 joerg

Don't depend on yacc to include stdlib.h or string.h.


1.36 26-Dec-2014 christos

allow turning off the bpf jit loading.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.35 15-Mar-2014 riastradh

branches: 1.35.4;
Convert right-recursive rules to left-recursive ones.

This should obviate the need for the workaround of a large stack in
order to handle many rules.

No change in the resulting plists.

ok rmind


1.34 14-Mar-2014 rmind

NPF: add support for "stateful-ends".


1.33 17-Feb-2014 rmind

npfctl: take into account all addresses when multiple interfaces are
specified in a set of elements.


1.32 13-Feb-2014 rmind

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.31 08-Feb-2014 rmind

NPF:
- Adjust the syntax - remove "inet" keyword in favour of more explicit
"inet4" for the address family. Consistent with "inet6" for IPv6.
- Adjust and improve the man page a little bit.


1.30 06-Feb-2014 rmind

Add support for CDB based NPF tables.


1.29 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.28 18-Nov-2013 rmind

Rename some tokens, use more accurate names (the current ones are incorrect
or missleading) and add few comments in the parser code.


1.27 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.26 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.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.


1.23 09-May-2013 christos

always allow hex where decimal is allowed.


Revision tags: agc-symver-base
1.22 20-Mar-2013 christos

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


1.21 18-Mar-2013 rmind

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


1.20 11-Mar-2013 christos

handle port "ftp-data"


1.19 10-Mar-2013 christos

deal with strings as interfaces


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 yamt-pagecache-base7
1.17 26-Nov-2012 rmind

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


1.16 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.15 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.14 02-Oct-2012 rmind

npfctl/yyerror(): print the right line number if we already parsed the line.


1.13 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.12 12-Aug-2012 rmind

branches: 1.12.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.11 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


1.10 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.9 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.8 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.


1.7 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


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

branches: 1.6.2;
remove extra rule that got merged...


1.5 26-Feb-2012 christos

- 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.4 26-Feb-2012 rmind

Simplify slightly: merge iface into addr_or_iface, use it in filt_addr.


Revision tags: netbsd-6-base
1.3 15-Jan-2012 rmind

branches: 1.3.2;
- 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.2 12-Jan-2012 christos

handle variables that contain variables


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: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 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 perseant-stdc-iso10646-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 agc-symver-base tls-maxphys-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
1.8 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: yamt-pagecache-base3 yamt-pagecache-base2
1.7 04-Nov-2011 zoltan

Add IPv6 support for NPF.


Revision tags: yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.6 02-Feb-2011 rmind

branches: 1.6.4;
NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


1.5 18-Jan-2011 rmind

branches: 1.5.2;
NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.4 18-Dec-2010 rmind

NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.


1.3 11-Nov-2010 rmind

NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
as NAT code et al, to use it. Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6. Various fixes and clean-up.


1.2 16-Sep-2010 rmind

NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.37 05-Jul-2025 joe

Temporarily remove dash and dot separated MAC address rule in scanner.

this avoids breaking existing configurations where spaceless port ranges are used
as the parser tries to resolve the MAC address rules instead.

Also, add a simple test for port ranges in the NPF rump test suite

@Greg Troxel


1.36 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.35 01-Jun-2025 joe

NPF copyright 2025


1.34 31-May-2025 joe

Userland: npf rule parser for user and group id


1.33 20-Mar-2025 christos

PR/58116: Attaulah: Allow comments inside lists in npf.conf


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.32 30-May-2020 rmind

branches: 1.32.8;
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.31 24-May-2020 rmind

PR/55288: npfctl: change parameter syntax to be more permissive.


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

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


Revision tags: netbsd-9-base
1.29 23-Jul-2019 rmind

branches: 1.29.2;
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 pgoyette-compat-20190127
1.28 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.27 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.26 10-Dec-2017 rmind

branches: 1.26.2; 1.26.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-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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 bouyer-socketcan-base pgoyette-localcount-20170107
1.25 03-Jan-2017 rmind

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


1.24 27-Dec-2016 rmind

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


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.23 22-Jan-2016 christos

branches: 1.23.2;
handle v4 mapped addresses


1.22 26-Dec-2014 christos

allow turning off the bpf jit loading.


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

branches: 1.21.2;
npfctl: allow group of zeroes in IPv6 address; noted by spz@.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.20 14-Mar-2014 rmind

branches: 1.20.2;
NPF: add support for "stateful-ends".


1.19 13-Feb-2014 rmind

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.18 08-Feb-2014 rmind

NPF:
- Adjust the syntax - remove "inet" keyword in favour of more explicit
"inet4" for the address family. Consistent with "inet6" for IPv6.
- Adjust and improve the man page a little bit.


1.17 06-Feb-2014 rmind

Add support for CDB based NPF tables.


1.16 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.15 18-Nov-2013 rmind

Rename some tokens, use more accurate names (the current ones are incorrect
or missleading) and add few comments in the parser code.


1.14 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.13 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"


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
1.12 20-Mar-2013 christos

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


1.11 18-Mar-2013 rmind

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


1.10 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 yamt-pagecache-base7
1.9 26-Nov-2012 rmind

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


1.8 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.7 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.6 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.5 19-Jul-2012 spz

branches: 1.5.2;
teach npf ipv6-icmp
reviewed by rmind@


1.4 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.3 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.


1.2 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
1.1 08-Jan-2012 rmind

branches: 1.1.2; 1.1.4;
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: perseant-exfatfs-base-20250801 netbsd-11-base
1.38 08-Jul-2025 joe

fix missing attribute for NAT in npfctl show/validate

it can now rightfully fetch the layer3 bit and use it to print rightly


1.37 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.36 01-Jun-2025 joe

NPF copyright 2025


1.35 01-Jun-2025 joe

npfctl: show user/group in retrieved rule


1.34 27-Jan-2025 mlelstv

Collect compiler marks for decompilation.
Fixes PR 58884


Revision tags: perseant-exfatfs-base-20240630 perseant-exfatfs-base
1.33 01-Aug-2023 andvar

branches: 1.33.2;
fix RCSIDs.


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.32 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.31 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.30 01-Nov-2019 christos

PR/54670: Azuma OKAMOTO: Consistently use 'W' for TH_CWN, and bump buffer
size.


1.29 10-Aug-2019 rmind

npfctl show/validate: fix couple bugs in multiple table/port representation.
Fixes PR/54122.


Revision tags: netbsd-9-base
1.28 23-Jul-2019 rmind

branches: 1.28.2;
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 pgoyette-compat-20190127
1.27 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.26 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.25 10-Dec-2017 rmind

branches: 1.25.2; 1.25.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-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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
1.24 14-May-2017 christos

don't print decimal and parse hex!


Revision tags: prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
1.23 29-Jan-2017 christos

branches: 1.23.2;
Always print the rule id associated with a rule.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
1.22 29-Dec-2016 rmind

branches: 1.22.2;
Improve 'npfctl debug' a little bit.


1.21 27-Dec-2016 christos

Add a list command to iterate over connection and nat endpoints.


1.20 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.19 03-Jun-2015 rmind

branches: 1.19.2;
npfctl: fix the from/to port mess up when showing the rules.


1.18 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.


1.17 02-Feb-2015 rmind

npfctl_print_rule: print the ID in hex, not decimal.


1.16 02-Feb-2015 rmind

npfctl(8): report dynamic rule ID in a comment, print the case when libpcap
is used correctly. Also, add npf_ruleset_dump() helper in the kernel.


Revision tags: tls-maxphys-base netbsd-7-base tls-earlyentropy-base
1.15 20-Jul-2014 rmind

branches: 1.15.2; 1.15.4;
formatting


1.14 31-May-2014 rmind

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.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.13 14-Mar-2014 rmind

branches: 1.13.2; 1.13.4;
NPF: add support for "stateful-ends".


1.12 19-Feb-2014 rmind

npfctl_print_nat: fix the byte-order of the port.


1.11 12-Feb-2014 rmind

npfctl_print_table: add a "cdb" type.


1.10 08-Feb-2014 rmind

NPF:
- Adjust the syntax - remove "inet" keyword in favour of more explicit
"inet4" for the address family. Consistent with "inet6" for IPv6.
- Adjust and improve the man page a little bit.


1.9 07-Feb-2014 rmind

NPF: add support for static (stateless) NAT.


1.8 22-Nov-2013 rmind

npfctl: need to rewind the list after calling print_table(). XXX libnpf.


1.7 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.6 19-Nov-2013 christos

CID 1129614: dereference after null


1.5 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.4 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.3 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.2 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.1 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.


1.16 20-Aug-2025 joe

PR bin/59511

when extracting variables for filtering in NPF, allow the handler to
recursively extract all variables that might be present in the parent variable
to fully get all the filter elements present in them. this issue poses a security risk
as intruders can find their way into your machine if you intend to block them
but have their IPs in a nested variable with other IPs as well.

so this needs to be pulled up to 9, 10, 11


this fix has been reviewed by christos@ and martin@ and tests have been included.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.15 01-Jun-2025 joe

NPF copyright 2025


1.14 31-May-2025 joe

Userland: npf rule parser for user and group id


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.13 30-May-2020 rmind

branches: 1.13.8;
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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127
1.12 19-Jan-2019 rmind

branches: 1.12.2;
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.11 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: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base 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 bouyer-socketcan-base
1.10 11-Jan-2017 christos

branches: 1.10.12; 1.10.14;
Don't silently take the first element of multiple element variables.


Revision tags: pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.9 12-Jul-2015 rmind

branches: 1.9.2;
- npfvar_get_type1: check for NULL first.
- Minor fix for the npf(7) man page.


Revision tags: netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.8 19-Nov-2013 rmind

branches: 1.8.4;
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.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
1.7 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.6 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.5 30-May-2012 rmind

branches: 1.5.2;
npfctl(8): add show-config command. Also, update syntax.


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

branches: 1.4.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.


Revision tags: netbsd-6-base
1.3 15-Jan-2012 rmind

branches: 1.3.2;
- 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.2 12-Jan-2012 christos

handle variables that contain variables


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.14 20-Aug-2025 joe

PR bin/59511

when extracting variables for filtering in NPF, allow the handler to
recursively extract all variables that might be present in the parent variable
to fully get all the filter elements present in them. this issue poses a security risk
as intruders can find their way into your machine if you intend to block them
but have their IPs in a nested variable with other IPs as well.

so this needs to be pulled up to 9, 10, 11


this fix has been reviewed by christos@ and martin@ and tests have been included.


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.13 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.12 01-Jun-2025 joe

NPF copyright 2025


1.11 31-May-2025 joe

Userland: npf rule parser for user and group id


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.10 30-May-2020 rmind

branches: 1.10.8;
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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
1.9 29-Sep-2018 rmind

branches: 1.9.2;
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: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE 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 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.8 19-Nov-2013 rmind

branches: 1.8.24; 1.8.26;
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.7 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 agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
1.6 26-Nov-2012 rmind

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


Revision tags: yamt-pagecache-base6
1.5 28-Oct-2012 rmind

Fix for npfctl show case. Improve some description while here.


1.4 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.3 19-Jul-2012 spz

branches: 1.3.2;
teach npf ipv6-icmp
reviewed by rmind@


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

branches: 1.2.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.


Revision tags: netbsd-6-base
1.1 08-Jan-2012 rmind

branches: 1.1.2;
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: perseant-exfatfs-base-20250801 netbsd-11-base netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.25 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 phil-wifi-20191119
1.24 30-Sep-2019 uwe

Use -width Pa for FILES.


1.23 30-Sep-2019 uwe

Fix pasto in table replace -t type


1.22 29-Sep-2019 rmind

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


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127
1.21 19-Jan-2019 rmind

branches: 1.21.2;
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 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.20 10-Dec-2017 rmind

branches: 1.20.2; 1.20.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-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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 bouyer-socketcan-base pgoyette-localcount-20170107
1.19 27-Dec-2016 christos

Document list


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
1.18 24-May-2016 wiz

branches: 1.18.2;
Fix typo. From Michael Scherer in PR 51162.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
1.17 03-Aug-2014 rmind

Cross-link npf(7).


1.16 23-Jul-2014 rmind

NPF: rework of the connection saving and restoring:
- Add support for saving a snapshot of the current connections together
with a full configuration. Support a reverse load operation. Eliminate
the old 'sess-save' and 'sess-load' in favour of the new mechanism.
- Share code between load and reload operations: the latter performs
load from npf.conf without affecting the connections.
- Simplify and fix races with connection loading.
- Bump NPF_VERSION.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.15 20-Sep-2013 wiz

branches: 1.15.2;
Remove trailing whitespace.


1.14 19-Sep-2013 rmind

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


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
1.13 16-Feb-2013 rmind

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


1.12 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 yamt-pagecache-base7
1.11 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.10 15-Nov-2012 rmind

npfctl(8): mention table listing.


Revision tags: yamt-pagecache-base6
1.9 13-Aug-2012 rmind

branches: 1.9.2;
- npfctl show: add most of the missing cases.
- Few minor improvements to NPF man pages.


1.8 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.7 27-Jun-2012 rmind

Fix and update npf.conf(5), npfctl(8) and its usage message.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
1.6 24-Mar-2011 jruoho

branches: 1.6.4; 1.6.6;
As per request from the author, put non-standard PERFORMANCE back.


1.5 22-Mar-2011 jruoho

Use 'offset indent' for the list of commands. Emphasize valid commands.
Remove PERFORMANCE (too small paragraph to warrant a section).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base
1.4 18-Jan-2011 rmind

NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.3 14-Sep-2010 kim

Fix remaining references for npf.conf(8) to npf.conf(5)


1.2 24-Aug-2010 rmind

Move npf.conf(5-8) into the correct section, hence npf.conf(5).


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.67 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.66 01-Jun-2025 joe

NPF copyright 2025


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
1.65 14-Jul-2021 christos

branches: 1.65.4;
PR/56307: Konrad Schroder: npfctl's error messages don't report the failing
filename.
Add the filename (but in quotes for consistency with other places in the file).
Also fix an err -> errx


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.64 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.


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

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


1.62 29-Sep-2019 rmind

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


1.61 21-Aug-2019 rmind

- npftest: fix a memleak in a unit test (standalone path only).
- Minor style fixes. No functional change.


Revision tags: netbsd-9-base
1.60 25-Jul-2019 rmind

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


1.59 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.58 03-Feb-2019 mrg

- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily


Revision tags: pgoyette-compat-20190127
1.57 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.56 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
1.55 13-Apr-2018 maxv

branches: 1.55.2;
Document "debug" in usage().


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.54 30-Oct-2017 ozaki-r

branches: 1.54.2;
Fix showing translated port (ntohs-ed twice wrongly)


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 bouyer-socketcan-base
1.53 11-Jan-2017 christos

branches: 1.53.6;
fix hint.


Revision tags: pgoyette-localcount-20170107
1.52 29-Dec-2016 rmind

Improve 'npfctl debug' a little bit.


1.51 27-Dec-2016 wiz

Sort options in usage.


1.50 27-Dec-2016 christos

Add a list command to iterate over connection and nat endpoints.


1.49 27-Dec-2016 christos

We don't use openssl for NPF in NetBSD, so don't include the header, and
provide a compatibility define.


1.48 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.47 29-Jun-2016 christos

branches: 1.47.2;
use sha1 from libc


1.46 04-Jan-2015 christos

load the config file before bpfjit so that we can disable the warning.


1.45 26-Dec-2014 christos

allow turning off the bpf jit loading.


1.44 26-Dec-2014 rmind

npfctl(8): attempt to preload bpfjit kernel module and print the
warning on failure.


1.43 11-Aug-2014 rmind

- Add and use npf_alg_export().
- npf_conn_import: handle NAT metadata correctly.
- npf_nat_newpolicy: restore the policy ID.
- npfctl_load: fix error code handling for the limit cases.
- npf_config_import: fix the inverted logic.
- npfctl_load: improve error handling.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
1.42 23-Jul-2014 htodd

branches: 1.42.2;
Build fix (use error when defined).


1.41 23-Jul-2014 rmind

NPF: rework of the connection saving and restoring:
- Add support for saving a snapshot of the current connections together
with a full configuration. Support a reverse load operation. Eliminate
the old 'sess-save' and 'sess-load' in favour of the new mechanism.
- Share code between load and reload operations: the latter performs
load from npf.conf without affecting the connections.
- Simplify and fix races with connection loading.
- Bump NPF_VERSION.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
1.40 12-Nov-2013 rmind

branches: 1.40.2;
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.39 19-Sep-2013 rmind

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


1.38 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.37 19-May-2013 rmind

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


Revision tags: agc-symver-base
1.36 18-Mar-2013 rmind

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


1.35 11-Mar-2013 christos

separate sess commands.


1.34 11-Mar-2013 christos

remove dup usage.


1.33 11-Mar-2013 christos

fix usage


1.32 10-Mar-2013 christos

centralize error handling and print what went wrong instead of "ioctl"


1.31 16-Feb-2013 rmind

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


1.30 10-Feb-2013 rmind

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


1.29 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.


1.28 01-Feb-2013 spz

IPv6 linklocal address printing cosmetics


Revision tags: yamt-pagecache-base8
1.27 24-Dec-2012 rmind

- Rework NPF's nbuf interface: use advancing and ensuring as a main method.
Eliminate unnecessary copy and simplify. Adapt regression tests.
- Simplify ICMP ALG a little. While here, handle ICMP ECHO for traceroute.
- Minor fixes, misc cleanup.


1.26 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.25 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.24 15-Nov-2012 rmind

npfctl: switch to ecalloc(3).


1.23 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


1.22 31-Oct-2012 martin

gcc 4.1 is not smart enough to notice "arg" is only used when initialized
correctly and produces a "might be used unintialized" warning.


Revision tags: yamt-pagecache-base6
1.21 29-Oct-2012 rmind

Implement NPF table listing and preservation of entries on reload.
Bump the version.


1.20 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.19 01-Sep-2012 rmind

branches: 1.19.2;
npfctl usage: minor formatting fix.


1.18 12-Aug-2012 rmind

- 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.17 19-Jul-2012 rmind

- npfctl_print_stats: beautification a la French style.
- npfctl_icmpcode: fix the build break.


1.16 19-Jul-2012 joerg

Add missing __dead.


1.15 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.14 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.13 27-Jun-2012 rmind

Fix and update npf.conf(5), npfctl(8) and its usage message.


1.12 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.


1.11 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
1.10 05-Feb-2012 rmind

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


1.9 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.8 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: yamt-pagecache-base3 yamt-pagecache-base2
1.7 04-Nov-2011 zoltan

Add IPv6 support for NPF.


Revision tags: yamt-pagecache-base
1.6 31-Aug-2011 joerg

branches: 1.6.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.5 02-Feb-2011 rmind

NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


1.4 18-Jan-2011 rmind

branches: 1.4.2;
NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.3 18-Dec-2010 rmind

NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.


1.2 11-Nov-2010 rmind

NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
as NAT code et al, to use it. Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6. Various fixes and clean-up.


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
1.56 01-Jul-2025 joe

userland code for layer 2 filtering in NPF

reviewed by christos@


1.55 01-Jun-2025 joe

NPF copyright 2025


1.54 31-May-2025 joe

Userland: npf rule parser for user and group id


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
1.53 30-May-2020 rmind

branches: 1.53.8;
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.52 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.51 30-Sep-2019 rmind

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


1.50 29-Sep-2019 rmind

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


1.49 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.48 23-Jul-2019 rmind

branches: 1.48.2;
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 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-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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

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 27-Dec-2016 christos

Add a list command to iterate over connection and nat endpoints.


1.40 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.39 26-Dec-2014 christos

branches: 1.39.2;
allow turning off the bpf jit loading.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
1.38 23-Jul-2014 rmind

branches: 1.38.2;
NPF: rework of the connection saving and restoring:
- Add support for saving a snapshot of the current connections together
with a full configuration. Support a reverse load operation. Eliminate
the old 'sess-save' and 'sess-load' in favour of the new mechanism.
- Share code between load and reload operations: the latter performs
load from npf.conf without affecting the connections.
- Simplify and fix races with connection loading.
- Bump NPF_VERSION.


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 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.34 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.33 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.32 19-Sep-2013 rmind

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


1.31 19-Sep-2013 rmind

NPF: G/C n-code in favour of BPF byte-code. Delete lots of code, mmm!


1.30 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 agc-symver-base
1.29 20-Mar-2013 christos

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


1.28 18-Mar-2013 rmind

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


1.27 16-Feb-2013 rmind

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


1.26 10-Feb-2013 rmind

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


1.25 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 yamt-pagecache-base7
1.24 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.23 26-Nov-2012 rmind

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


1.22 05-Nov-2012 rmind

npfctl: switch to efun(3) routines.


Revision tags: yamt-pagecache-base6
1.21 29-Oct-2012 rmind

Implement NPF table listing and preservation of entries on reload.
Bump the version.


1.20 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.19 12-Aug-2012 rmind

branches: 1.19.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.18 19-Jul-2012 spz

teach npf ipv6-icmp
reviewed by rmind@


1.17 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.16 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.15 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.


1.14 30-May-2012 rmind

npfctl(8): add show-config command. Also, update syntax.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
1.13 10-Mar-2012 christos

Add a small disassembler.


1.12 26-Feb-2012 christos

- 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.


Revision tags: netbsd-6-base
1.11 05-Feb-2012 rmind

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


1.10 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.9 10-Jan-2012 joerg

Use __dead


1.8 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: yamt-pagecache-base3 yamt-pagecache-base2
1.7 04-Nov-2011 zoltan

Add IPv6 support for NPF.


Revision tags: yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
1.6 02-Feb-2011 rmind

branches: 1.6.4;
NPF checkpoint:
- Add libnpf(3) - a library to control NPF (configuration, ruleset, etc).
- Add NPF support for ftp-proxy(8).
- Add rc.d script for NPF.
- Convert npfctl(8) to use libnpf(3) and thus make it less depressive.
Note: next clean-up step should be a parser, once dholland@ will finish it.
- Add more documentation.
- Various fixes.


1.5 18-Jan-2011 rmind

branches: 1.5.2;
NPF checkpoint:
- Add the concept of rule procedure: separate normalization, logging and
potentially other functions from the rule structure. Rule procedure can be
shared amongst the rules. Separation is both at kernel level (npf_rproc_t)
and configuration ("procedure" + "apply").
- Fix portmap sharing for NAT policy.
- Update TCP state tracking logic. Use TCP FSM definitions.
- Add if_byindex(), OK by matt@. Use in logging for the lookup.
- Fix traceroute ALG and many other bugs; misc clean-up.


Revision tags: matt-mips64-premerge-20101231
1.4 18-Dec-2010 rmind

NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.


1.3 11-Nov-2010 rmind

NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
as NAT code et al, to use it. Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6. Various fixes and clean-up.


1.2 16-Sep-2010 rmind

NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.


1.1 22-Aug-2010 rmind

Import NPF - a packet filter. Some features:

- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
supporting generic RISC-like and specific CISC-like instructions for
common patterns (e.g. IPv4 address matching). See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@


Revision tags: perseant-exfatfs-base-20250801 perseant-exfatfs-base-20240630 perseant-exfatfs-base cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421 phil-wifi-20200411 phil-wifi-20200406 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415
1.16 08-Apr-2018 maxv

Move NPF's todo list into src/doc/TODO.npf, and add some entries. After a
conversation (two months ago) with rmind and sborrill.


Revision tags: pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
1.15 10-Dec-2017 rmind

branches: 1.15.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.


1.14 10-Dec-2017 leot

Fix a typo


1.13 10-Dec-2017 christos

Add things implemented


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 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 bouyer-socketcan-base
1.12 11-Jan-2017 christos

more todo


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
1.11 14-Feb-2014 rmind

branches: 1.11.4; 1.11.10;
G/C some todo items


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
1.10 13-Mar-2013 christos

branches: 1.10.4;
more explicit syntax


1.9 13-Mar-2013 christos

more todo's


1.8 13-Mar-2013 christos

add another


1.7 11-Mar-2013 christos

one more fixed


1.6 11-Mar-2013 christos

more breakage.


1.5 11-Mar-2013 christos

explain further.


1.4 11-Mar-2013 christos

fix usage


1.3 11-Mar-2013 christos

handle port "ftp-data"


1.2 11-Mar-2013 christos

more


1.1 11-Mar-2013 christos

my laundry list