]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agooutput/lua: better lua output setup error handling 3272/head
Richard Sailer [Thu, 22 Feb 2018 00:53:16 +0000 (01:53 +0100)] 
output/lua: better lua output setup error handling

If suricata was started with --init-errors-fatal and an error occured
during setup of lua output (like if lua scripts configured in the conf file
don't exist or are not readable) suricata continued, which did not reflect
"init errors fatal" very well.

This fix makes the suricata initialization abort and send an error message
in such cases.

For details see:
https://redmine.openinfosecfoundation.org/issues/1503

7 years agooutput/lua: remove unnecessary detect.h include
Richard Sailer [Thu, 22 Feb 2018 00:27:59 +0000 (01:27 +0100)] 
output/lua: remove unnecessary detect.h include

output-lua.c contained an include of detect.h.

Since we don't (and shouldn't) call any functions from detect.c in output-lua.c
and such coupling is generally unwanted this patch removes that include.

7 years agoRust: add 'debug' feature
Pierre Chifflier [Tue, 6 Mar 2018 20:33:33 +0000 (21:33 +0100)] 
Rust: add 'debug' feature

The 'debug' feature is enabled if suricata was configured with the
--enabled-debug' flag.
If enabled, the SCLogDebug format and calls the logging function as
usual. Otherwise, this macro is a no-op (similarly to the C code).

7 years agoprofiling: suppress debug statements 3271/head
Victor Julien [Mon, 5 Mar 2018 17:37:17 +0000 (18:37 +0100)] 
profiling: suppress debug statements

7 years agoprelude: add protocol information through JSON
Thomas Andrejak [Thu, 8 Jun 2017 12:56:26 +0000 (14:56 +0200)] 
prelude: add protocol information through JSON

7 years agounified2: fix xff extra-data output (Bug #2305)
Daniel Humphries [Mon, 4 Dec 2017 19:53:27 +0000 (19:53 +0000)] 
unified2: fix xff extra-data output (Bug #2305)

In extra-data mode, suricata does not output xff data without
undocumented conditions (including enabling packet output). This
behaviour has been fixed to remove the hidden requirements. Fix
included removing previous xff data output implementation and adding a
new function for outputting xff that is called after outputting each
event.

IPv6 XFF entries were also being recorded incorrectly as if they were
IPv4 and this has been fixed.

7 years agodoc: update eve json output for DNS and HTTP
Pascal Delalande [Thu, 22 Feb 2018 21:28:56 +0000 (22:28 +0100)] 
doc: update eve json output for DNS and HTTP

7 years agoder/afl: free data during fuzzing
Victor Julien [Mon, 5 Mar 2018 08:11:30 +0000 (09:11 +0100)] 
der/afl: free data during fuzzing

7 years agooutput: fix logging wrong direction in tls upgrade 3263/head
Victor Julien [Fri, 2 Mar 2018 12:44:43 +0000 (13:44 +0100)] 
output: fix logging wrong direction in tls upgrade

When upgrading to TLS from HTTP logging of the final HTTP tx could
have the wrong direction. This was due to the original packet triggering/
finalizing the upgrade would be used as the base for both the toserver
and toclient pseudo packet meaning it was wrong in one direction.

This patch creates a pseudo packet in the same way as the flow timeout
code does, so it no longer takes the raw original packet in.

Bug #2430

7 years agooutput/json: update callers to use explicit directions
Victor Julien [Fri, 2 Mar 2018 11:15:11 +0000 (12:15 +0100)] 
output/json: update callers to use explicit directions

7 years agooutput/json: make log direction explicit
Victor Julien [Fri, 2 Mar 2018 10:53:12 +0000 (11:53 +0100)] 
output/json: make log direction explicit

Introduce enum OutputJsonLogDirection to make logging direction
explicit.

7 years agooutput/json: clean up CreateJSONHeader calls
Victor Julien [Fri, 2 Mar 2018 10:36:36 +0000 (11:36 +0100)] 
output/json: clean up CreateJSONHeader calls

7 years agotravis: redirect unittest output to file in all builds
Jason Ish [Thu, 1 Mar 2018 13:42:09 +0000 (07:42 -0600)] 
travis: redirect unittest output to file in all builds

On error, print the last 500 lines of output then exit 1.

Shoud allow us to see why a build fail on the debug tests,
when the error was burried in an output file we weren't
making visible.

7 years agorust/json: add array_append_string
Victor Julien [Mon, 26 Feb 2018 12:35:28 +0000 (13:35 +0100)] 
rust/json: add array_append_string

7 years agorust/dns: fix nom verbose error mode
Victor Julien [Mon, 19 Feb 2018 17:24:14 +0000 (18:24 +0100)] 
rust/dns: fix nom verbose error mode

7 years agodoc: use standard spelling of daemon
Brandon Sterne [Tue, 27 Feb 2018 21:28:45 +0000 (13:28 -0800)] 
doc: use standard spelling of daemon

7 years agosource-pcap-file: Directory mode may miss files (bug #2394)
Danny Browning [Thu, 21 Dec 2017 21:09:08 +0000 (14:09 -0700)] 
source-pcap-file: Directory mode may miss files (bug #2394)

https://redmine.openinfosecfoundation.org/issues/2394

Certain parameters of delay and poll interval could cause newly added
files in a directory to be missed. Cleaned up how time is handled for
files in a directory and fix which time is used for future directory
traversals. Add a mutex to make sure processing time is not optimized
away.

7 years agoebpf: remove vlan_hdr alignement
Eric Leblond [Mon, 12 Feb 2018 23:04:05 +0000 (00:04 +0100)] 
ebpf: remove vlan_hdr alignement

If we align the vlan_hdr then we increase its size and the parsing
of packets with VLAN tag is broken.

7 years agoepf: improving the ebpf makefile
Jesper Dangaard Brouer [Wed, 7 Feb 2018 22:21:24 +0000 (23:21 +0100)] 
epf: improving the ebpf makefile

The current ebpf/Makefile.am have the problem that clang compile
errors still result in an ELF .bpf output file.  This is obviously
problematic as the problem is first seen runtime when loading
the bpf-prog.  This is caused by the uses of a pipe from
clang to llc.

To address this problem, split up the clang and llc invocations
up into two separate commands, to get proper reaction based on
the compiler exit code. The clang compiler is used as a
frontend (+ optimizer) and instructed (via -S -emit-llvm) to
generate LLVM IR (Intermediate Representation) with suffix .ll.
The LLVM llc command is used as a compiler backend taking IR and
producing BPF machine bytecode, and storing this into a ELF
object.  In the last step the IR .ll suffix code it removed.

The official documentation of the IR language:
 http://llvm.org/docs/LangRef.html

Also fix the previous make portability warning:
 '%-style pattern rules are a GNU make extension'
I instead use some static pattern rules:
 https://www.gnu.org/software/make/manual/html_node/Static-Usage.html

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
7 years agoebpf: compile with clang -target bpf
Jesper Dangaard Brouer [Wed, 7 Feb 2018 22:21:19 +0000 (23:21 +0100)] 
ebpf: compile with clang -target bpf

Enable compiling eBPF programs with clang -target bpf.

This is mostly to workaround a bug in libbpf, where clang > ver 4.0.0
generates some ELF sections (.eh_frame) when -target bpf is NOT specified,
and libbpf fails loading such files.

Notice libbpf is provided by the kernel, and in kernel v4.16 the library
will contain the needed function for attaching to the XDP hook.

Kernel commit 949abbe88436 ("libbpf: add function to setup XDP")
 https://git.kernel.org/torvalds/c/949abbe88436

The library fix has reached kernel v4.16 but the workaround for Suricata
is interesting anyway in case people use a kernel v4.15.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
7 years agoebpf: take clang -target bpf include issue of stdint.h into account
Jesper Dangaard Brouer [Wed, 7 Feb 2018 22:21:14 +0000 (23:21 +0100)] 
ebpf: take clang -target bpf include issue of stdint.h into account

This patch prepares code before enabling the clang -target bpf.

The clang compiler does not like #include <stdint.h> when
using '-target bpf' it will fail with:

 fatal error: 'gnu/stubs-32.h' file not found

This is because using clang -target bpf, then clang will have '__bpf__'
defined instead of '__x86_64__' hence the gnu/stubs-32.h include
attempt as /usr/include/gnu/stubs.h contains, on x86_64:

  #if !defined __x86_64__
  # include <gnu/stubs-32.h>
  #endif
  #if defined __x86_64__ && defined __LP64__
  # include <gnu/stubs-64.h>
  #endif
  #if defined __x86_64__ && defined __ILP32__
  # include <gnu/stubs-x32.h>
  #endif

This can be worked around by installing the 32-bit version of
glibc-devel.i686 on your distribution.

But the BPF programs does not really need to include stdint.h,
if converting:
  uint64_t -> __u64
  uint32_t -> __u32
  uint16_t -> __u16
  uint8_t  -> __u8

This patch does this type syntax conversion.

The build of a ebpf files had an issue for system like Debian
because they don't have a asm/types.h in the include path if the
architecture is not defined which is the case due to target bpf.

This results in:

 clang-5.0 -Wall -Iinclude -O2 \
         -D__KERNEL__ -D__ASM_SYSREG_H \
         -target bpf -S -emit-llvm vlan_filter.c -o vlan_filter.ll
 In file included from vlan_filter.c:19:
 In file included from include/linux/bpf.h:11:
 /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not
 found
 #include <asm/types.h>
          ^~~~~~~~~~~~~
 1 error generated.
 Makefile:523: recipe for target 'vlan_filter.bpf' failed

This patch fixes the issue by adding a include path setting the
architecture to the one of the builder.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
Sidned-off-by: Eric Leblond <eric@regit.org>
7 years agofile: fix files not getting pruned 3247/head
Victor Julien [Tue, 13 Feb 2018 12:42:39 +0000 (13:42 +0100)] 
file: fix files not getting pruned

When the filedata logger is enabled (file extraction), but a file is not
stored due to no rules matching to force this, the file would never be
freed.

This was caused by a check in the file pruning logic that only freed a
file when the FILE_STORED flag was set. However files can also have the
FILE_NOSTORE flag set which indicates that a file won't be stored.

This patch makes sure that both conditions lead to file pruning.

7 years agostream: inform app layer of depth reached
Victor Julien [Mon, 12 Feb 2018 17:31:14 +0000 (18:31 +0100)] 
stream: inform app layer of depth reached

7 years agoflash: code cleanups 3246/head
Victor Julien [Fri, 2 Feb 2018 14:45:47 +0000 (15:45 +0100)] 
flash: code cleanups

7 years agodetect/bsize: tests for http_request_line
Victor Julien [Tue, 19 Dec 2017 17:00:38 +0000 (18:00 +0100)] 
detect/bsize: tests for http_request_line

7 years agodetect: bsize keyword
Victor Julien [Sun, 10 Dec 2017 20:39:50 +0000 (21:39 +0100)] 
detect: bsize keyword

Allows matching on stickybuffers. Like dsize, it allows matching on
exact values, greater than and less than, and ranges.

For streaming buffers, such as HTTP bodies, the final size of the
body is only known at the end of the transaction.

7 years agorule analyzer: simple rules to json dumper
Victor Julien [Fri, 3 Nov 2017 11:33:53 +0000 (12:33 +0100)] 
rule analyzer: simple rules to json dumper

7 years agodetect/content: pass START/END flags to inspection
Victor Julien [Mon, 18 Dec 2017 16:11:15 +0000 (17:11 +0100)] 
detect/content: pass START/END flags to inspection

7 years agodetect: set implied flow direction based on keywords
Victor Julien [Fri, 3 Nov 2017 11:29:49 +0000 (12:29 +0100)] 
detect: set implied flow direction based on keywords

7 years agodetect/dns_query: move to API v2. Supports transforms.
Victor Julien [Wed, 1 Nov 2017 07:33:37 +0000 (08:33 +0100)] 
detect/dns_query: move to API v2. Supports transforms.

7 years agofile_data: update to API v2
Victor Julien [Wed, 1 Nov 2017 07:33:09 +0000 (08:33 +0100)] 
file_data: update to API v2

As we can have multiple files per TX we use the multi inspect
buffer support.

By using this API file_data supports transforms.

Redo part of the flash decompression as a hard coded built-in sort
of transform.

7 years agodetect/http_request_line: convert to inspect api v2
Victor Julien [Wed, 1 Nov 2017 07:32:31 +0000 (08:32 +0100)] 
detect/http_request_line: convert to inspect api v2

7 years agodetect/transform: initial to_sha256 implementation
Victor Julien [Thu, 26 Oct 2017 06:14:14 +0000 (08:14 +0200)] 
detect/transform: initial to_sha256 implementation

Takes input buffer and replaces it with hash value for that buffer.
Hash value is in raw bytes.

7 years agodetect/transform: initial compress_whitespace implementation
Victor Julien [Wed, 25 Oct 2017 07:27:02 +0000 (09:27 +0200)] 
detect/transform: initial compress_whitespace implementation

7 years agodetect/transform: initial strip_whitespace implementation
Victor Julien [Thu, 26 Oct 2017 08:20:07 +0000 (10:20 +0200)] 
detect/transform: initial strip_whitespace implementation

7 years agodetect/prefilter: move hash into detect engine ctx
Victor Julien [Tue, 31 Oct 2017 12:49:42 +0000 (13:49 +0100)] 
detect/prefilter: move hash into detect engine ctx

7 years agodetect/prefilter: add de_ctx to registration
Victor Julien [Tue, 31 Oct 2017 11:20:20 +0000 (12:20 +0100)] 
detect/prefilter: add de_ctx to registration

7 years agodetect: move mpm engines into detect engine ctx
Victor Julien [Mon, 30 Oct 2017 21:37:42 +0000 (22:37 +0100)] 
detect: move mpm engines into detect engine ctx

This allows safe registration at runtime.

7 years agodetect/inspect engines: copy to detect engine ctx
Victor Julien [Mon, 30 Oct 2017 18:42:35 +0000 (19:42 +0100)] 
detect/inspect engines: copy to detect engine ctx

Register rule-time engines in the detect engine. This is necessary
now that rule parsing can create new buffers.

7 years agodetect: register dynamic buffers into de_ctx
Victor Julien [Mon, 30 Oct 2017 16:14:34 +0000 (17:14 +0100)] 
detect: register dynamic buffers into de_ctx

Register buffers that are created during rule parsing. Currently
this means an existing buffer with one or more transformations.

7 years agocontent inspection: support transforms
Victor Julien [Mon, 23 Oct 2017 11:27:32 +0000 (13:27 +0200)] 
content inspection: support transforms

Make sure content is applied to the transformed version of a buffer.

Support content with its modifiers, and also isdataat, pcre, bytetest
and bytejump.

7 years agodetect: move buffer type map into detect ctx
Victor Julien [Mon, 30 Oct 2017 08:43:42 +0000 (09:43 +0100)] 
detect: move buffer type map into detect ctx

Move previously global table into detect engine ctx. Now that we
can register buffers at rule loading time we need to take concurrency
into account.

Move DetectBufferType to detect.h and update DetectBufferCtx API calls
to include a detect engine ctx reference.

7 years agodetect: prefilter/inspect API v2, with transforms
Victor Julien [Tue, 23 Jan 2018 11:25:33 +0000 (12:25 +0100)] 
detect: prefilter/inspect API v2, with transforms

Introduce InspectionBuffer a structure for passing data between
prefilters, transforms and inspection engines.

At rule parsing time, we'll register new unique 'DetectBufferType's
for a 'parent' buffer (e.g. pure file_data) with its transformations.
Each unique combination of buffer with transformations gets it's
own buffer id.

Similarly, mpm registration and inspect engine registration will be
copied from the 'parent' (again, e.g. pure file_data) to the new id's.

The transforms are called from within the prefilter engines themselves.

Provide generic MPM matching and setup callbacks. Can be used by
keywords to avoid needless code duplication. Supports transformations.

Use unique name for profiling, to distinguish between pure buffers
and buffers with transformation.

Add new registration calls for mpm/prefilters and inspect engines.

Inspect engine api v2: Pass engine to itself. Add generic engine that
uses GetData callback and other registered settings.

The generic engine should be usable for every 'simple' case where
there is just a single non-streaming buffer. For example HTTP uri.

The v2 API assumes that registered MPM implements transformations.

Add util func to set new transform in rule and add util funcs for rule
parsing.

7 years agodetect: prep for dynamic smlists arrays in sigs
Victor Julien [Mon, 23 Oct 2017 10:08:47 +0000 (12:08 +0200)] 
detect: prep for dynamic smlists arrays in sigs

Initialize Signature::init_data::smlists like normal, but before use
expand them if needed.

7 years agodocs: remove many outdated and old install docs
Andreas Herz [Tue, 13 Feb 2018 22:41:47 +0000 (23:41 +0100)] 
docs: remove many outdated and old install docs

7 years agodocs: replace redmine links and enforce https on oisf urls
Andreas Herz [Tue, 13 Feb 2018 21:06:33 +0000 (22:06 +0100)] 
docs: replace redmine links and enforce https on oisf urls

7 years agoapp-layer: remove has events callback - not used
Jason Ish [Mon, 12 Feb 2018 19:43:59 +0000 (13:43 -0600)] 
app-layer: remove has events callback - not used

7 years agodnp3: regenerate object decoding code
Jason Ish [Fri, 26 Jan 2018 22:15:09 +0000 (16:15 -0600)] 
dnp3: regenerate object decoding code

7 years agodnp3-gen: require jinja2 v2.10 or later
Jason Ish [Fri, 26 Jan 2018 22:14:11 +0000 (16:14 -0600)] 
dnp3-gen: require jinja2 v2.10 or later

Previous versions, but not all, have issues tracking
variables.

7 years agodnp3-gen: fix heap buffer overflow in generated code
Philippe Antoine [Fri, 26 Jan 2018 22:09:18 +0000 (16:09 -0600)] 
dnp3-gen: fix heap buffer overflow in generated code

Due to missing check before memcpy.

7 years agoder: fix recursion depth not being handled correctly
Victor Julien [Fri, 2 Feb 2018 10:17:23 +0000 (11:17 +0100)] 
der: fix recursion depth not being handled correctly

In a mix of sequences the 'depth reached' error would not
be fully propagated.

Found with AFL.

7 years agoder: warn if null passed to decoders
Victor Julien [Fri, 2 Feb 2018 10:56:16 +0000 (11:56 +0100)] 
der: warn if null passed to decoders

Remove null checks for errcode.

7 years agotm-threads: fix build warning in afl mode
Eric Leblond [Tue, 26 Dec 2017 19:14:24 +0000 (20:14 +0100)] 
tm-threads: fix build warning in afl mode

7 years agodetect: fix out of bounds write in detect thread space creation
Victor Julien [Mon, 11 Dec 2017 13:07:14 +0000 (14:07 +0100)] 
detect: fix out of bounds write in detect thread space creation

7 years agomodbus: duplicate alerts unaware of direction 3230/head
David DIALLO [Wed, 7 Feb 2018 23:20:09 +0000 (00:20 +0100)] 
modbus: duplicate alerts unaware of direction

Remove DetectAppLayerInspectEngineRegister for TOCLIENT direction
because Modbus inspection engine is only performing in request (TOSERVER).

Detect Value keyword in read access rule. In read access, match on value
is not possible.

Update Modbus keyword documentation.

7 years agorust: update 'external' api for app layer changes
Pierre Chifflier [Thu, 8 Feb 2018 18:41:49 +0000 (19:41 +0100)] 
rust: update 'external' api for app layer changes

Remove unused HasTxDetectState function and remove state argument
from SetTxDetectState.

Update NTP code.

7 years agoconf/yaml: don't allow empty key values
Jason Ish [Wed, 7 Feb 2018 21:11:54 +0000 (15:11 -0600)] 
conf/yaml: don't allow empty key values

When loading an empty file, libyaml will fire a single scalar
event causing us to create a key that contains an empty string.
We're not interested in this, so skip an empty scalar value
when expecting a key.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2418

7 years agometadata: fix parsing when not k/v
Jason Ish [Mon, 5 Feb 2018 21:34:09 +0000 (15:34 -0600)] 
metadata: fix parsing when not k/v

Allows for parsing metadata with mixed single word and key/val
pairs.

7 years agorust/dns: simplify tx freeing 3223/head
Victor Julien [Tue, 6 Feb 2018 10:24:50 +0000 (11:24 +0100)] 
rust/dns: simplify tx freeing

Now that we no longer need the state when freeing a TX, we can simply
do cleanup from the Drop trait.

7 years agoapp-layer: remove unused HasTxDetectState call
Victor Julien [Tue, 6 Feb 2018 10:12:56 +0000 (11:12 +0100)] 
app-layer: remove unused HasTxDetectState call

Also remove the now useless 'state' argument from the SetTxDetectState
calls. For those app-layer parsers that use a state == tx approach,
the state pointer is passed as tx.

Update app-layer parsers to remove the unused call and update the
modified call.

7 years agonfs: remove old test code
Victor Julien [Tue, 6 Feb 2018 09:35:05 +0000 (10:35 +0100)] 
nfs: remove old test code

7 years agoapp-layer: add tx iterator API
Victor Julien [Wed, 31 Jan 2018 14:58:21 +0000 (15:58 +0100)] 
app-layer: add tx iterator API

Until now, the transaction space is assumed to be terse. Transactions
are handled sequentially so the difference between the lowest and highest
active tx id's is small. For this reason the logic of walking every id
between the 'minimum' and max id made sense. The space might look like:

    [..........TTTT]

Here the looping starts at the first T and loops 4 times.

This assumption isn't a great fit though. A protocol like NFS has 2 types
of transactions. Long running file transfer transactions and short lived
request/reply pairs are causing the id space to be sparse. This leads to
a lot of unnecessary looping in various parts of the engine, but most
prominently: detection, tx house keeping and tx logging.

    [.T..T...TTTT.T]

Here the looping starts at the first T and loops for every spot, even
those where no tx exists anymore.

Cases have been observed where the lowest tx id was 2 and the highest
was 50k. This lead to a lot of unnecessary looping.

This patch add an alternative approach. It allows a protocol to register
an iterator function, that simply returns the next transaction until
all transactions are returned. To do this it uses a bit of state the
caller must keep.

The registration is optional. If no iterator is registered the old
behaviour will be used.

7 years agodoc: improve eBPF and XDP doc
Eric Leblond [Fri, 2 Feb 2018 20:39:14 +0000 (21:39 +0100)] 
doc: improve eBPF and XDP doc

Remove reference to `buggy` clang as a workaround has been found in
libbpf.

Proof read and add information on the structure of eBPF code.

7 years agoutil-ebpf: rename local variable
Eric Leblond [Wed, 31 Jan 2018 20:20:52 +0000 (21:20 +0100)] 
util-ebpf: rename local variable

7 years agoaf-packet: count only CPUs once
Eric Leblond [Wed, 31 Jan 2018 20:12:59 +0000 (21:12 +0100)] 
af-packet: count only CPUs once

7 years agodoc: update documentation
Eric Leblond [Fri, 26 Jan 2018 09:14:44 +0000 (10:14 +0100)] 
doc: update documentation

This patch adds info on kernel requirement for XDP and rework a few
things.

7 years agoebpf: allow modified build of xdp_filter
Eric Leblond [Fri, 26 Jan 2018 09:11:56 +0000 (10:11 +0100)] 
ebpf: allow modified build of xdp_filter

Using BUILD_CPUMAP constant will allow user to use XDP bypass on
kernel prior to 4.15.

7 years agoebpf: improve xdp-cpu-redirect distribution in xdp_filter.c
Jesper Dangaard Brouer [Thu, 25 Jan 2018 19:24:38 +0000 (20:24 +0100)] 
ebpf: improve xdp-cpu-redirect distribution in xdp_filter.c

The XDP CPU destination array/set, configured via xdp-cpu-redirect,
will always be fairly small.  My different benchmarking showed that
the current modulo hashing into the CPU array can easily result in bad
distribution, expecially if the number of CPU is an even number.

This patch uses a proper hashing function on the input key. The key
used for hashing is inspired by the ippair hashing code in
src/tmqh-flow.c, and is based on the IP src + dst.

An important property is that the hashing is flow symmetric, meaning
that if the source and destintation gets swapped then the selected CPU
will remain the same.  This is important for Suricate.

That hashing INITVAL (15485863 the 10^6th prime number) was fairly
arbitrary choosen, but experiments with kernel tree pktgen scripts
(pktgen_sample04_many_flows.sh +pktgen_sample05_flow_per_thread.sh)
showed this improved the distribution.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
7 years agoebpf: add Paul Hsieh's (LGPL 2.1) hash function SuperFastHash
Jesper Dangaard Brouer [Thu, 25 Jan 2018 19:24:33 +0000 (20:24 +0100)] 
ebpf: add Paul Hsieh's (LGPL 2.1) hash function SuperFastHash

Adjusted function call API to take an initval. This allow the API
user to set the initial value, as a seed. This could also be used for
inputting the previous hash.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
7 years agodoc: how to get live info about ebpf behavior
Eric Leblond [Wed, 17 Jan 2018 15:59:23 +0000 (16:59 +0100)] 
doc: how to get live info about ebpf behavior

7 years agounix-socket: add ebpf-bypassed-stats command
Eric Leblond [Wed, 17 Jan 2018 02:45:01 +0000 (03:45 +0100)] 
unix-socket: add ebpf-bypassed-stats command

This command output the count of element in IPv4 and IPv6 flow
table of interfaces using eBPF/XDP bypass.

7 years agounix-socket: add bypassed counter to iface-stat
Eric Leblond [Wed, 17 Jan 2018 02:28:20 +0000 (03:28 +0100)] 
unix-socket: add bypassed counter to iface-stat

7 years agoutil-ebpf: add bypassed counters
Eric Leblond [Wed, 17 Jan 2018 02:24:58 +0000 (03:24 +0100)] 
util-ebpf: add bypassed counters

Use LiveDevice bypassed counter and also add hash size counters
for the v4 and v6 flow table.

7 years agoebpf: maintain a copy of kernel UAPI header file linux/bpf.h
Jesper Dangaard Brouer [Mon, 15 Jan 2018 18:31:27 +0000 (19:31 +0100)] 
ebpf: maintain a copy of kernel UAPI header file linux/bpf.h

7 years agoebpf: fix detection of llc
Eric Leblond [Fri, 12 Jan 2018 15:18:34 +0000 (16:18 +0100)] 
ebpf: fix detection of llc

7 years agodoc: add info about xdp IPS bypass
Eric Leblond [Thu, 11 Jan 2018 15:56:18 +0000 (16:56 +0100)] 
doc: add info about xdp IPS bypass

7 years agoaf-packet: XDP bypass in IPS mode
Eric Leblond [Mon, 8 Jan 2018 23:25:02 +0000 (00:25 +0100)] 
af-packet: XDP bypass in IPS mode

Implement XDP bypass in IPS mode by using XDP redirect to send
packets from bypassed flow directly to the transmission interface.

7 years agoflow-bypass: introduce update function
Eric Leblond [Tue, 9 Jan 2018 22:11:23 +0000 (23:11 +0100)] 
flow-bypass: introduce update function

Main objective of the function is to be able to bypass a flow on
other interfaces. This is necessary in AF_PACKET case as the flow
table are per interface.

7 years agoebpf: add some comments to eBPF filter
Eric Leblond [Sun, 7 Jan 2018 21:05:40 +0000 (22:05 +0100)] 
ebpf: add some comments to eBPF filter

7 years agoebpf: slight bypass_filter optimization
Eric Leblond [Sun, 7 Jan 2018 20:58:09 +0000 (21:58 +0100)] 
ebpf: slight bypass_filter optimization

7 years agoutil-ebpf: simplify code cleaning
Eric Leblond [Sun, 7 Jan 2018 20:47:43 +0000 (21:47 +0100)] 
util-ebpf: simplify code cleaning

Avoid to use an unnecessary callback strategy as the purpose of the
function using the callback is hardcoded.

7 years agoaf-packet: add comments to eBPF/XDP code
Eric Leblond [Sun, 7 Jan 2018 12:16:27 +0000 (13:16 +0100)] 
af-packet: add comments to eBPF/XDP code

7 years agoaf-packet: fix error handling in bypass case
Eric Leblond [Sun, 7 Jan 2018 12:15:37 +0000 (13:15 +0100)] 
af-packet: fix error handling in bypass case

If the key is already in the hash table then the bypass is
succesful.

7 years agoutil-ebpf: fix libbpf error handling
Eric Leblond [Sun, 7 Jan 2018 11:59:16 +0000 (12:59 +0100)] 
util-ebpf: fix libbpf error handling

7 years agodoc: document XDP CPU redirect
Eric Leblond [Thu, 11 Jan 2018 15:52:21 +0000 (16:52 +0100)] 
doc: document XDP CPU redirect

7 years agoaf-packet: add support for XDP cpu redirect map
Eric Leblond [Tue, 2 Jan 2018 21:08:21 +0000 (22:08 +0100)] 
af-packet: add support for XDP cpu redirect map

This patch adds a boolean option "xdp-cpu-redirect" to af-packet
interface configuration. If set, then the XDP filter will load
balance the skb creation on specified CPUs instead of doing the
creation on the CPU handling the packet. In the case of a card
with asymetric hashing this will allow to avoid saturating the
single CPU handling the trafic.

The XDP filter must contains a set of map allowing load balancing.
This is the case of xdp_filter.bpf.

Fixed-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
7 years agoebpf: import more recent version of helpers
Eric Leblond [Tue, 2 Jan 2018 18:30:00 +0000 (19:30 +0100)] 
ebpf: import more recent version of helpers

7 years agoutil-affinity: export CPU set parsing function
Eric Leblond [Sat, 6 Jan 2018 08:44:00 +0000 (09:44 +0100)] 
util-affinity: export CPU set parsing function

7 years agoaf-packet: code cleaning and comments
Eric Leblond [Fri, 5 Jan 2018 22:32:54 +0000 (23:32 +0100)] 
af-packet: code cleaning and comments

7 years agoaf-packet: add missing copyright header
Eric Leblond [Fri, 5 Jan 2018 12:27:59 +0000 (13:27 +0100)] 
af-packet: add missing copyright header

And also fixes the copyright date in some files.

7 years agoutil-ebpf: add error handling in hash value fetch
Eric Leblond [Tue, 2 Jan 2018 11:50:26 +0000 (12:50 +0100)] 
util-ebpf: add error handling in hash value fetch

7 years agodoc: update xdp documentation
Eric Leblond [Fri, 5 Jan 2018 18:31:43 +0000 (19:31 +0100)] 
doc: update xdp documentation

Also remove configuration info from yaml as they are now in the
documentation.

7 years agodoc: add XDP setup documentation
Peter Manev [Sat, 30 Dec 2017 21:11:35 +0000 (22:11 +0100)] 
doc: add XDP setup documentation

7 years agoaf-packet: improve xdp error handling
Eric Leblond [Sat, 30 Dec 2017 21:04:04 +0000 (22:04 +0100)] 
af-packet: improve xdp error handling

Don't try to bypass the flow if the flow table is unknown.

Also continue after error message if ever XDP was not correctly
setup.

7 years agoaf-packet: add support for multi iface bypass
Eric Leblond [Tue, 26 Dec 2017 21:55:55 +0000 (22:55 +0100)] 
af-packet: add support for multi iface bypass

7 years agoutil-device: change logic of registration
Eric Leblond [Sat, 30 Dec 2017 18:50:12 +0000 (19:50 +0100)] 
util-device: change logic of registration

Device storage requires the devices to be created after storage
is finalized so we need to first get the list of devices then
create them when the storage is finalized.

This patch introduces the LiveDeviceName structure that is a list
of device name used during registration.

Code uses LiveRegisterDeviceName for pre registration and keep
using the LiveRegisterDevice function for part of the code that
create the interface during the runmode creation.

7 years agoutil-device: add an iteration function
Eric Leblond [Tue, 26 Dec 2017 21:47:44 +0000 (22:47 +0100)] 
util-device: add an iteration function

7 years agodevice-storage: introduce feature
Eric Leblond [Mon, 1 Jan 2018 23:33:23 +0000 (00:33 +0100)] 
device-storage: introduce feature

The capture method may have to store data depending related to the
offloading so having a per interface storage via LiveDevice seems
interesting.

7 years agoflow-bypass: fix sleep strategy
Eric Leblond [Thu, 28 Dec 2017 18:17:56 +0000 (19:17 +0100)] 
flow-bypass: fix sleep strategy

7 years agotm-threads: fix build warning in afl mode
Eric Leblond [Tue, 26 Dec 2017 19:14:24 +0000 (20:14 +0100)] 
tm-threads: fix build warning in afl mode