Commit Graph

97 Commits

Author SHA1 Message Date
mrg 4cf2909a7b used __diagused where appropriate. 2013-10-30 08:41:38 +00:00
rmind ace4567cf1 npf_session_setnat: fix the race condition when the old connection is still
being expired while a new/duplicate is being created.
2013-10-29 16:39:10 +00:00
rmind e5a13e2c75 Add NPF_MAX_RULES, an artificial limit (set it to 1M). 2013-10-27 16:22:08 +00:00
martin 6a2419fedf Turn a few __unused into __diagused 2013-10-25 11:35:55 +00:00
rmind fb41d25668 sess_hash_bucket: convert to murmurhash2, include ports, use random seed. 2013-09-26 00:24:36 +00:00
rmind 7b5edfdc0d NPF: G/C n-code in favour of BPF byte-code. Delete lots of code, mmm! 2013-09-19 01:49:07 +00:00
rmind 4e592132ab - 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.
2013-09-19 01:04:45 +00:00
rmind 60d47add10 npfctl_rule: fixes for the dynamic rules. 2013-09-19 00:50:56 +00:00
rmind cb633e2d0c Add bpf_filter_ext() to use with BPF COP, restore bpf_filter() as it was
originally to preserve compatibility.  Similarly, add bpf_validate_ext()
which takes bpf_ctx_t.
2013-09-18 23:34:55 +00:00
rmind 4c45c55542 bpf_filter: add a custom argument which can be passed to coprocessor routine. 2013-08-30 15:00:08 +00:00
rmind 1962fa8781 Implement BPF_COP/BPF_COPX instructions in the misc category (BPF_MISC)
which add a capability to call external functions in a predetermined way.

It can be thought as a BPF "coprocessor" -- a generic mechanism to offload
more complex packet inspection operations.  There is no default coprocessor
and this functionality is not targeted to the /dev/bpf.  This is primarily
targeted to the kernel subsystems, therefore there is no way to set a custom
coprocessor at the userlevel.

Discussed on: tech-net@
OK: core@
2013-08-29 14:25:40 +00:00
rmind 878c5e5866 - npf_cache_ip: re-fetch IPv6 header since nbufs might have been reallocated.
- npf_cache_all: clear NBUF_DATAREF_RESET since npf_cache_ip() handles it.
2013-08-23 10:37:03 +00:00
rmind f04a92b1d6 - Rewrite parts of pfil(9): use array to store hooks and thus be more cache
friendly (there are only few hooks in the system).  Make the structures
  opaque and the interface more strict.
- Remove PFIL_HOOKS option by making pfil(9) mandatory.
2013-06-29 21:06:57 +00:00
rmind bdfcfdcad8 - NPF connection tracking: rework synchronisation on tracking disable/enable
points and document it.  Split the worker thread into a separate module
  with an interface, so it could be re-used for other tasks.
- Replace ALG list with arrays and thus hit fewer cache lines.
- Misc bug fixes.
2013-06-02 02:20:04 +00:00
rmind ce38978248 - Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.
2013-05-19 20:45:34 +00:00
christos bc0f55de88 Make ALG's autoloadable by providing in the config file:
alg "algname"
2013-03-20 00:29:46 +00:00
rmind 4183ea5f53 Always use BPF JIT for NPF rules (using BPF code) if it is available. 2013-03-18 02:24:45 +00:00
rmind 9ef92dc6c0 npf_session_establish: fix previous. 2013-03-18 00:17:20 +00:00
rmind 3b8a2fcf9c Add npf_session_trackable_p() and npf_session_fillent() for the common code.
Simplify.  No functional change.
2013-03-18 00:14:57 +00:00
christos ff7550039b add missing argument 2013-03-13 13:15:47 +00:00
christos fbfb5d3d8e don't auto-unload 2013-03-13 02:34:37 +00:00
christos 2c132b3129 normali{s,z}e 2013-03-12 20:47:48 +00:00
christos 12e775eb94 use sizeof(req) to find if it was empty or not (from uwe) 2013-03-11 17:20:02 +00:00
christos d89c031d8b *"" is not constant according to gcc. So we move the responsibility for adding
a , to the users of the macro.
2013-03-11 17:03:55 +00:00
christos 02ab91fbba - avoid trailing , in dependencies when there are none other the npf module
itself.
- remove if_npflog dependency from npf_ext_log.
2013-03-11 16:37:43 +00:00
christos fea1d0b382 prevent the lookup function from autoloading recursively. 2013-03-11 01:56:37 +00:00
christos 7e25e6910f move the module loading in the correct place. 2013-03-11 01:43:50 +00:00
christos 1066afcd4f remove the detach that does not belong here anymore. 2013-03-11 01:42:12 +00:00
christos 45d28ff77c Split the npflog cloner and auto-load the extensions. 2013-03-10 20:51:44 +00:00
rmind 3ae8914252 nbuf_ensure_contig: fix assert (can be equal if there is zero-length mbuf).
Found by npftest on sparc64.
2013-02-19 23:57:37 +00:00
rmind 56910be779 - Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs.  Also, update the man page.
2013-02-16 21:11:12 +00:00
rmind 50c5afcad4 - Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.
2013-02-10 23:47:37 +00:00
rmind 0e21825481 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.
2013-02-09 03:35:31 +00:00
rmind 3107fd1eb5 - nbuf_ensure_contig: rework to use m_ensure_contig(9), which will not free
the mbuf chain on failure.  Fixes some corner cases.  Improve regression
  test and sprinkle some asserts.
- npf_reassembly: clear nbuf on IPv6 reassembly failure path (partial fix).
  The problem was found and fix provided by Anthony Mallet.
2013-01-20 18:45:56 +00:00
rmind 2be35e5206 Silence gcc in npf_recache(). 2012-12-24 23:11:25 +00:00
rmind 352f160615 - 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.
2012-12-24 19:05:42 +00:00
rmind 57ff5416fd - 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.
2012-12-23 21:01:03 +00:00
rmind f9e6e88c89 npf_rwrcksum: handle delayed checksums in the network stack; also fix
non-NPF_NAT_PORTS case and add some comments.  PR/47235.
2012-12-10 01:11:13 +00:00
rmind 333cdb0c5a Add NPF "rndblock" extension to randomly drop packets (using a random function
with a percentage or modulo operation).  This is a demo module, although it can
be used for packet loss simulation.  Example of a procedure in npf.conf:

procedure "somedrop" {
	# Drop 1.9% of the traffic
	rndblock: percentage 1.9
}
2012-12-10 00:32:23 +00:00
rmind af7272417a npf_table_list: avoid triggering assert on diagnostic. 2012-12-04 19:28:16 +00:00
rmind 64647e51e4 Implement NPF table listing and preservation of entries on reload.
Bump the version.
2012-10-29 02:27:11 +00:00
rmind f5f72a013e npf_tcp_inwindow: inspect the sequence numbers even if the packet contains no
data, fixing up only the RST to the initial SYN.  This makes off-path attacks
more difficult.  For the reference, see "Reflection Scan: an Off-Path Attack
on TCP" by Jan Wrobel.
2012-10-06 23:50:17 +00:00
rmind 1fb2724b4f npf_packet_handler: drop the packet if IPv6 reassembly did not work. 2012-10-06 23:38:20 +00:00
mlelstv b7abe5ff3b ext_ops does not change during the life cycle and can be fetched without
the mutex held. This avoids confusion in the compiler about an uninitialized
variable ext_ops.
ok rmind@
2012-10-03 12:24:56 +00:00
rmind 8c6e21bf5e 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.
2012-09-16 13:47:41 +00:00
rmind 0c665aa87f npf_icmp_uniqid: split into npf_icmp_uniqid4() and npf_icmp_uniqid6() parts. 2012-09-16 13:44:14 +00:00
joerg 3a9c89f51f Mark npf_session_worker as __dead. 2012-09-13 21:09:36 +00:00
rmind bea61aedea npf_icmp_uniqid: inspect the correct npc_info for IPv4/v6. 2012-09-10 21:42:53 +00:00
rmind e0cfa502eb Add npf_state_setsampler() for _NPF_TESTING case. This also fixes the build. 2012-08-15 19:47:38 +00:00
rmind 49540518f9 - {npf_mk_rproc,npf_nat_save}: fix the fetching of {rproc-ptr,id_ptr}.
- npf_rproc_setlog: initialise variables to 0, as keys may not exist.

Bugs found by mlelstv@ while testing on Amiga.
2012-08-15 18:44:56 +00:00