Commit Graph

295 Commits

Author SHA1 Message Date
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
uwe
61417cee53 Actually, according to the grammar the square brackets in the "tcp
flags" are not literal, so use .Op to show that /mask is optional.
2019-01-08 11:36:10 +00:00
uwe
94cd499daa Restore macro with effect. Fix the real problem that prevented it to
have the effect.
2019-01-08 11:28:01 +00:00
wiz
65808c7ffa New sentence, new line. Punctuation fixes. Remove macros without effect. 2019-01-08 10:25:26 +00:00
gutteridge
a7a743c1a4 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.
2019-01-08 01:19:16 +00:00
rmind
39013e66c1 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.
2018-09-29 14:41:35 +00:00
uwe
97e384e7bd According to the grammar and examples the static table is defined with
"file" keyword, not "static".
2018-09-21 10:59:11 +00:00
uwe
6da1ab24a9 Improve markup. 2018-09-21 09:42:18 +00:00
maxv
62994698cf Wrap long lines, so that nothing overflows. 2018-09-21 07:22:26 +00:00
maxv
657923ce43 Switch back to tabs, it was nicer this way. 2018-09-19 15:36:12 +00:00
maxv
bc58a324f2 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.
2018-09-04 15:36:01 +00:00
wiz
0394df431b New sentence, new line. Use Fn for functions. 2018-09-02 18:03:23 +00:00
maxv
c09ea90fc6 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.
2018-09-02 17:45:18 +00:00
wiz
25be4c69af Remove superfluous Pp. 2018-09-01 19:26:46 +00:00
rmind
b5635267ab 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).
2018-09-01 16:28:57 +00:00
maxv
e3e075e240 rename net-seg -> map-seg, and document it 2018-08-31 11:18:35 +00:00
maxv
e6e69c66e8 "interface" already contains "var-name", so don't mention it in "filt-addr",
that's redundant
2018-08-31 11:11:21 +00:00
maxv
7af2b2f68b should be port-opts 2018-08-31 11:01:09 +00:00
maxv
20048da297 Clarify the "Groups" section. 2018-08-31 10:52:30 +00:00
maxv
918cd75c72 remove commented reference to pflog 2018-08-31 10:38:17 +00:00
wiz
367a79e6ff Add missing -width; remove unnecessary .Pp. 2018-08-27 13:20:47 +00:00
maxv
6cf056e7fd Improve the "Map" section. 2018-08-27 13:09:16 +00:00
maxv
c4abcc5a94 Document ALGs. 2018-08-27 12:46:03 +00:00
maxv
5458b5faf0 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.
2018-08-17 12:20:49 +00:00
maxv
143312eb5c Add missing quote in static-rule, it causes man-k.org (and other tools)
to wrongly highlight the grammar.
2018-08-17 12:04:20 +00:00
maxv
1dbf263b8b Replace "rproc"->"proc" in the grammar (spotted by he@), and slightly
reword.
2018-08-17 10:24:19 +00:00
maxv
f8cd5f425f Replace () by [] in tcp-flags.
Fix proc-opts, the value is optional, noted by he@.
2018-08-17 10:16:24 +00:00
maxv
29f7e3440d Improve wording. 2018-08-16 09:58:00 +00:00
maxv
ded4e9d920 Improve the "Map" section a little. 2018-08-16 09:50:37 +00:00
maxv
16b11b4076 Document the "flags" keyword. 2018-08-16 09:46:18 +00:00