Commit Graph

324 Commits

Author SHA1 Message Date
rillig c0be2f13b9 npfctl: remove no-op NOLINT definition
Setting NOLINT must be done before including <bsd.own.mk> to have an
effect.
2023-09-14 20:03:56 +00:00
tnn 00e8851994 npfctl: adapt to new libpcap API 2023-08-18 14:26:50 +00:00
riastradh 18140ab7da npftest(8): No need for weird padding any more.
cdbw_output never needed it at runtime, and the declaration no longer
makes gcc angry about not having it.
2023-08-08 10:35:48 +00:00
andvar 1e7139f024 fix RCSIDs. 2023-08-01 20:09:12 +00:00
mrg 1115bcb541 cdbw_output()'s 3rd argument must be a 16-byte char array, so pad the
string literals passed to it with enough nuls to make this true.

found by GCC 12.
2023-08-01 07:57:17 +00:00
kardel 57cb3743d4 PR kern/55654:
Switch default for parameter npf ip4.reassembly to 1.
This makes the NPF default configuration comply with host
requirements for IPv4.
2023-02-12 13:21:28 +00:00
christos 3df5232c9f Handle warnings and errors from pcap_activate properly (from bch) 2022-04-30 13:20:09 +00:00
christos fe67084211 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
2021-07-14 09:15:01 +00:00
martin 5c18a11ba1 Allow to set sanitizer flags for the rump build from the
build.sh command line, like: -V RUMP_SANITIZE=address
2021-07-07 11:51:45 +00:00
taca 8202121906 Change second gc.interval_min to gc.interval_max.
Obviously, second gc.interval_min should be gc.interval_max.

Should be pulled up to netbnsd-9.
2020-12-17 05:33:06 +00:00
abs c30a39f078 Fix tcpdump example from "‐i npflog0.pcap" to "‐i npflog0" 2020-10-30 09:23:36 +00:00
riastradh b13ab56848 npftest: Wait at least one tick in each gc busy wait iteration.
Otherwise the busy wait loop runs a little too fast for the gc about
half the times I run the test.

XXX We should really arrange mstohz to round up!
2020-08-27 18:51:20 +00:00
riastradh fdedb3494c npf: Make sure to initialize portmap_lock only once.
PR kern/55586
2020-08-27 18:50:25 +00:00
wiz 55eb855c31 Use more markup. 2020-06-06 20:38:00 +00:00
tnn e097843b4c npf-params.7: s/filer/filter/ 2020-05-31 16:32:07 +00:00
rmind a55d34090b npf-params(7): fix the state.key defaults. 2020-05-31 15:57:15 +00:00
rmind 231831948d npftest -- npf_test_init(): add a workaround for NetBSD. 2020-05-30 21:00:31 +00:00
rmind b899bfd96f 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.
2020-05-30 14:16:56 +00:00
rmind 3f8b631875 PR/55288: npfctl: change parameter syntax to be more permissive. 2020-05-24 15:35:39 +00:00
rmind 07861232b4 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@).
2020-05-23 19:56:00 +00:00
christos d0951ebe8b more nofifofs lossage 2020-05-16 12:42:11 +00:00
joerg c69153879d npftest_mbufops and npftest_ifops are owned by npf_mbuf_subr.c 2020-04-23 00:27:45 +00:00
christos 42e1450d6f PR/54670: Azuma OKAMOTO: Consistently use 'W' for TH_CWN, and bump buffer
size.
2019-11-01 13:58:32 +00:00
uwe 1497865af5 Use -width Pa for FILES. 2019-09-30 21:06:16 +00:00
uwe e1b6f38e10 Fix pasto in table replace -t type 2019-09-30 20:53:12 +00:00
uwe 052f05e3b3 Use -width Pa for FILES. 2019-09-30 20:44:51 +00:00
rmind 04cb50ac51 libnpf/npfctl: support dynamic NAT rulesets using a name prefix. 2019-09-30 00:37:11 +00:00
rmind 18d62e57fc npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.

(missed a file in previous commit; cvs is so helpful..)
2019-09-29 18:51:08 +00:00
rmind fc0df3a9c7 npfctl: implement table replace subcommand.
Contributed by Timshel Knoll-Miller.
2019-09-29 16:58:35 +00:00
rmind 298883fee6 - 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.
2019-08-25 13:21:03 +00:00
rmind 0dd7abe473 libnpf fix: link the library itself to libnv; libnpf users should not be
expected to assume this dependency.
2019-08-24 13:20:52 +00:00
rmind f916b9b1ff - npftest: fix a memleak in a unit test (standalone path only).
- Minor style fixes.  No functional change.
2019-08-21 21:41:53 +00:00
gutteridge 1e1742aedb npf.7: add xref to npf-params.7
(Adding directly here since this particular file isn't included in
rmind@'s upstream GitHub repo at present.)
2019-08-11 22:27:15 +00:00
rmind 04ad65d955 Adjust some internal NPF APIs:
* npfkern: use the npfk_ prefix.
* NPF portmap: amend the API so it could be used elsewhere.
* Make npf_connkey_t public.
2019-08-11 20:26:33 +00:00
rmind b7b9a92305 npf-params(7): add more bpf.jit details.
From David H. Gutteridge.
2019-08-11 20:25:14 +00:00
rmind 64b4ec4316 npfctl show/validate: fix couple bugs in multiple table/port representation.
Fixes PR/54122.
2019-08-10 22:23:55 +00:00
rmind 54d339ec04 NPF: fix BPF byte-code generation for a port-range used in a group.
Resolved PR/52609 and PR/54169.
2019-08-08 21:29:15 +00:00
rmind 7e067de4e0 npftest: fix double-free in npf_nbuf_test(). 2019-07-25 01:18:05 +00:00
rmind d3a92e4d77 npfctl: fix the bpf.jit parameter handling. 2019-07-25 00:48:55 +00:00
rmind a6ad2858b4 Install the npf-params(7) man page. 2019-07-25 00:02:55 +00:00
wiz ea75629060 Add RCS Id. 2019-07-23 14:24:02 +00:00
wiz 7f55a9275e New sentence, new line. Avoid formatting punctuation. Remove superfluous Pp. 2019-07-23 14:20:22 +00:00
rmind dadc88e3b0 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.
2019-07-23 00:52:01 +00:00
bad 48e354a3ed Get rid of all the -lrumpdev and -lrumpvfs that are no longer needed
after moving rump's mainbus from rumpdev to rumpkern.

Produces the same atf-run results as before.
2019-05-13 17:55:07 +00:00
tih d3100ce6fd 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
2019-04-17 20:41:58 +00:00
wiz add3cd5b0e Improve wording. 2019-04-08 07:58:45 +00:00
rmind 0694a143e0 npf.conf(5): Add more info about ifaddrs(). 2019-04-07 22:23:40 +00:00
mrg 82974f2217 check for snprintf() truncation and fail sanely if so, rather than
attempting to use a file that won't exist or isn't secure.
2019-02-04 08:21:11 +00:00
mrg fbffadb9f8 - 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
2019-02-03 03:19:25 +00:00
rmind 3d9a792dd8 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).
2019-01-19 21:19:31 +00:00