]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
9 years agoutil-ioctcl: increase header size 2129/head
Eric Leblond [Tue, 31 May 2016 13:55:31 +0000 (15:55 +0200)] 
util-ioctcl: increase header size

Headers can contain VLAN or Qing so we need to increase the value
returned by GetIfaceMaxHWHeaderLength.

9 years agosuricata: fix double packet processing threads
Andreas Herz [Tue, 31 May 2016 21:18:06 +0000 (23:18 +0200)] 
suricata: fix double packet processing threads

With the additional ParseInterfacesList the packet processing threads
were doubled since the Interface was included twice unless the device
was passed via the commandline with af-packet=IF.
The additonal ParseInterfacesList isn't necessary so remove it again

9 years agoac-ks: don't allow use on big-endian
Victor Julien [Tue, 31 May 2016 14:58:29 +0000 (16:58 +0200)] 
ac-ks: don't allow use on big-endian

9 years agoflow-worker: small cleanups
Victor Julien [Mon, 30 May 2016 16:01:02 +0000 (18:01 +0200)] 
flow-worker: small cleanups

9 years agodetect: make pattern matcher messages less verbose
Victor Julien [Mon, 30 May 2016 15:55:27 +0000 (17:55 +0200)] 
detect: make pattern matcher messages less verbose

9 years agoyaml: replace ac-tile by ac-ks
Victor Julien [Mon, 30 May 2016 15:52:43 +0000 (17:52 +0200)] 
yaml: replace ac-tile by ac-ks

9 years agoyaml: remove conf_filename global
Victor Julien [Tue, 31 May 2016 14:21:50 +0000 (16:21 +0200)] 
yaml: remove conf_filename global

conf_filename was a global pointer to the filename of the yaml.

Move into SCInstance. This reduces it's scope and cleans up the code.

9 years agoprofiling: fix compilation if libjansson is missing 2124/head
Victor Julien [Tue, 31 May 2016 12:41:31 +0000 (14:41 +0200)] 
profiling: fix compilation if libjansson is missing

9 years agopfring: cleanup
Victor Julien [Tue, 31 May 2016 12:22:00 +0000 (14:22 +0200)] 
pfring: cleanup

9 years agopfring: improve profiling
Victor Julien [Tue, 31 May 2016 12:18:04 +0000 (14:18 +0200)] 
pfring: improve profiling

Reset packet profiling after pfring_recv. The packet was taken from
the packet pool before this call. The packet will already have it's
start ticks initialized. To avoid including ticks while pfring_recv
waits for traffic, reset the ticks right after it.

9 years agoprofiling: allow packet profiling to be reset
Victor Julien [Tue, 31 May 2016 12:17:35 +0000 (14:17 +0200)] 
profiling: allow packet profiling to be reset

9 years agocoverity: fix CID 1362014
Eric Leblond [Tue, 31 May 2016 09:21:31 +0000 (11:21 +0200)] 
coverity: fix CID 1362014

Error handling was not correct regarding ring buffer memory
handling.

9 years agoaf-packet: use better defaults if config is missing
Victor Julien [Tue, 31 May 2016 11:44:16 +0000 (13:44 +0200)] 
af-packet: use better defaults if config is missing

9 years agoyaml: make eve log in yaml depend on libjansson 2121/head
Victor Julien [Tue, 31 May 2016 06:57:07 +0000 (08:57 +0200)] 
yaml: make eve log in yaml depend on libjansson

9 years agoyaml: improve capture comments
Victor Julien [Tue, 31 May 2016 06:51:57 +0000 (08:51 +0200)] 
yaml: improve capture comments

9 years agoyaml: move classification etc below the rules
Victor Julien [Tue, 31 May 2016 06:51:15 +0000 (08:51 +0200)] 
yaml: move classification etc below the rules

9 years agoyaml: new defaults for outputs
Victor Julien [Tue, 31 May 2016 06:50:45 +0000 (08:50 +0200)] 
yaml: new defaults for outputs

Enable eve.flow, disable plain http.log.

9 years agoyaml: file logging at info level
Victor Julien [Mon, 30 May 2016 19:32:17 +0000 (21:32 +0200)] 
yaml: file logging at info level

9 years agoyaml: improved defaults and misc cleanups
Victor Julien [Mon, 30 May 2016 19:30:25 +0000 (21:30 +0200)] 
yaml: improved defaults and misc cleanups

9 years agoyaml: add performance tuning section
Victor Julien [Mon, 30 May 2016 19:21:20 +0000 (21:21 +0200)] 
yaml: add performance tuning section

9 years agoyaml: more reshuffling
Victor Julien [Mon, 30 May 2016 19:10:44 +0000 (21:10 +0200)] 
yaml: more reshuffling

9 years agoyaml: create advancted sections
Victor Julien [Mon, 30 May 2016 17:38:46 +0000 (19:38 +0200)] 
yaml: create advancted sections

Sections for advancted detection settings and traffic tracking and
reconstruction.

9 years agoyaml: add hw accel section, move cuda there
Victor Julien [Mon, 30 May 2016 17:33:00 +0000 (19:33 +0200)] 
yaml: add hw accel section, move cuda there

9 years agoyaml: add netfilter section
Victor Julien [Mon, 30 May 2016 17:30:33 +0000 (19:30 +0200)] 
yaml: add netfilter section

9 years agoyaml: move outputs to the logging step
Victor Julien [Mon, 30 May 2016 17:28:34 +0000 (19:28 +0200)] 
yaml: move outputs to the logging step

9 years agoyaml: introduce 'advanced settings'
Victor Julien [Mon, 30 May 2016 17:19:56 +0000 (19:19 +0200)] 
yaml: introduce 'advanced settings'

9 years agoyaml: move app layer up
Victor Julien [Mon, 30 May 2016 17:15:41 +0000 (19:15 +0200)] 
yaml: move app layer up

9 years agoyaml: move afpacket, pcap, pcap-file up
Victor Julien [Mon, 30 May 2016 17:10:31 +0000 (19:10 +0200)] 
yaml: move afpacket, pcap, pcap-file up

9 years agoyaml: move logging up
Victor Julien [Mon, 30 May 2016 17:02:17 +0000 (19:02 +0200)] 
yaml: move logging up

9 years agoyaml: move rules up in the file
Victor Julien [Mon, 30 May 2016 16:57:20 +0000 (18:57 +0200)] 
yaml: move rules up in the file

Also disable decoder and stream events by default, as they are too noisy
in a untuned environment.

9 years agoyaml: move vars to the top
Victor Julien [Mon, 30 May 2016 16:53:52 +0000 (18:53 +0200)] 
yaml: move vars to the top

9 years agologging: clean up at shutdown
Victor Julien [Tue, 31 May 2016 02:22:47 +0000 (04:22 +0200)] 
logging: clean up at shutdown

9 years agoflow worker: move UDP app-layer into main function 2118/head
Victor Julien [Sun, 29 May 2016 09:29:30 +0000 (11:29 +0200)] 
flow worker: move UDP app-layer into main function

This way it's more clean what happens and we can profile it.

9 years agoflow worker: profiling
Victor Julien [Sun, 29 May 2016 08:40:46 +0000 (10:40 +0200)] 
flow worker: profiling

Previously the detect and stream code lived in their own thread
modules. This meant profiling showed their cost as part of the
thread module profiling logic. Now that only the flow worker is
a thread module this no longer works.

This patch introduces profiling for the 3 current flow worker
steps: flow, stream, detect.

9 years agodebug: fix compiler warnings 2115/head
Victor Julien [Sat, 28 May 2016 07:21:05 +0000 (09:21 +0200)] 
debug: fix compiler warnings

9 years agothread modules: remove unused id's
Victor Julien [Fri, 27 May 2016 14:46:03 +0000 (16:46 +0200)] 
thread modules: remove unused id's

9 years agodetect: no longer a thread module
Victor Julien [Fri, 27 May 2016 14:39:14 +0000 (16:39 +0200)] 
detect: no longer a thread module

Like stream, detect is now invoked directly by the FlowWorker.

9 years agostream-tcp: more cleanups
Victor Julien [Fri, 27 May 2016 14:10:59 +0000 (16:10 +0200)] 
stream-tcp: more cleanups

9 years agostream-tcp: no longer register as a thread module
Victor Julien [Fri, 27 May 2016 14:02:06 +0000 (16:02 +0200)] 
stream-tcp: no longer register as a thread module

Now that the FlowWorker handles the TCP Stream directly, having
the TCP engine as a thread module is no longer needed.

This patch removes the registration.

9 years agodrmemory: broader suppressions for hyperscan
Victor Julien [Fri, 27 May 2016 12:54:36 +0000 (14:54 +0200)] 
drmemory: broader suppressions for hyperscan

9 years agosmtp: improve thread data use
Victor Julien [Fri, 27 May 2016 10:14:16 +0000 (12:14 +0200)] 
smtp: improve thread data use

The SMTP app layer used a thread local data structure for the mpm in
reply parsing, but it only used a pmq. The MpmThreadCtx was actually
global. Until now this wasn't really noticed because non of the mpm's
used the thread ctx.

Hyperscan does use it however.

This patch creates a new structure SMTPThreadCtx, which contains both
the pmq and the mpm thread ctx. It's passed directly to the reply
parsing function instead of storing a pointer to it in the SMTPState.

Additionally fix a small memory leak warning wrt the smtp global mpm
state.

9 years agoapp-layer-smtp: free mpm contexts on shutdown
Justin Viiret [Wed, 25 May 2016 01:47:24 +0000 (11:47 +1000)] 
app-layer-smtp: free mpm contexts on shutdown

Adds a cleanup function for the SMTP parser that destroys the MPM
context and MPM thread context it uses.

Also marks smtp_mpm_thread_ctx static.

9 years agodetect-engine: log MPM/SPM matchers being used
Justin Viiret [Mon, 23 May 2016 04:22:30 +0000 (14:22 +1000)] 
detect-engine: log MPM/SPM matchers being used

9 years agompm: add "auto" default for mpm-algo
Justin Viiret [Mon, 23 May 2016 00:46:53 +0000 (10:46 +1000)] 
mpm: add "auto" default for mpm-algo

Setting mpm-algo to "auto" will use "hs" if Suricata was built against
Hyperscan, and "ac" otherwise (or "ac-tile" on Tilera platforms).

9 years agoapp-layer-detect-proto: use mpm-algo
Justin Viiret [Mon, 23 May 2016 03:46:24 +0000 (13:46 +1000)] 
app-layer-detect-proto: use mpm-algo

Use the matcher configured by the user rather than hard-coding MPM_AC.

9 years agoapp-layer-detect-proto: pass mpm_ctx to DestroyCtx
Justin Viiret [Mon, 23 May 2016 03:42:05 +0000 (13:42 +1000)] 
app-layer-detect-proto: pass mpm_ctx to DestroyCtx

The MPM DestroyCtx function accepts the MpmCtx, not the ctx pointer
inside it.

9 years agodetect-engine: adjust unit tests for hs mpm
Justin Viiret [Mon, 23 May 2016 01:58:01 +0000 (11:58 +1000)] 
detect-engine: adjust unit tests for hs mpm

The Hyperscan MPM does match deduplication internally (using
HS_FLAG_SINGLEMATCH) and only returns the number of unique matches,
unlike AC.

9 years agoapp-layer-smtp: init mpm thread ctx after prepare
Justin Viiret [Mon, 23 May 2016 01:06:39 +0000 (11:06 +1000)] 
app-layer-smtp: init mpm thread ctx after prepare

This allows the Hyperscan MPM to correctly allocate scratch.

9 years agompm-hs: make errors from hs_scan() fatal
Justin Viiret [Mon, 23 May 2016 03:57:50 +0000 (13:57 +1000)] 
mpm-hs: make errors from hs_scan() fatal

Hyperscan will only return an error at scan time if the database or
scratch region are corrupted, which should provoke a fatal error.

9 years agompm-hs,spm-hs: don't call hs_scan() for zero bytes
Justin Viiret [Mon, 23 May 2016 04:06:00 +0000 (14:06 +1000)] 
mpm-hs,spm-hs: don't call hs_scan() for zero bytes

9 years agonetmap: close sw ring before hw rings
Aleksey Katargin [Wed, 25 May 2016 04:45:07 +0000 (09:45 +0500)] 
netmap: close sw ring before hw rings
Fix issue #1714

9 years agotls-json-log: register module as tls-json-log, not dns-json-log
Jason Ish [Thu, 26 May 2016 17:44:19 +0000 (11:44 -0600)] 
tls-json-log: register module as tls-json-log, not dns-json-log

Fixes issue:
https://redmine.openinfosecfoundation.org/issues/1792
where dns-json-log would not log any data.

9 years agoprscript: fix error handling
Eric Leblond [Fri, 27 May 2016 07:16:02 +0000 (09:16 +0200)] 
prscript: fix error handling

Last result was used as global result.

9 years agoisdataat: remove unused code
Victor Julien [Tue, 24 May 2016 14:57:16 +0000 (16:57 +0200)] 
isdataat: remove unused code

9 years agosrc/: fix typo: receieved vs received 2095/head
Arturo Borrero Gonzalez [Mon, 23 May 2016 10:32:34 +0000 (12:32 +0200)] 
src/: fix typo: receieved vs received

Reported by Debian's lintian tool.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
9 years agoflow worker: set up decoder thread vars
Victor Julien [Sat, 21 May 2016 12:22:13 +0000 (14:22 +0200)] 
flow worker: set up decoder thread vars

9 years agoac: allow use of 31bits of pid space instead of 16 2092/head
Victor Julien [Fri, 22 Apr 2016 10:57:41 +0000 (12:57 +0200)] 
ac: allow use of 31bits of pid space instead of 16

9 years agodns: add support for sshfp records
Victor Julien [Wed, 23 Sep 2015 14:34:40 +0000 (16:34 +0200)] 
dns: add support for sshfp records

Update parser to process the records.

Update json output to log it.

9 years agocoverity: CID 1362011: Control flow issues (DEADCODE)
Victor Julien [Fri, 20 May 2016 16:45:16 +0000 (18:45 +0200)] 
coverity: CID 1362011: Control flow issues (DEADCODE)

9 years agocoverity: CID 1362012: Incorrect expression (EVALUATION_ORDER)
Victor Julien [Fri, 20 May 2016 16:42:46 +0000 (18:42 +0200)] 
coverity: CID 1362012: Incorrect expression (EVALUATION_ORDER)

9 years agocoverity CID 1362013: Control flow issues (NESTING_INDENT_MISMATCH)
Victor Julien [Fri, 20 May 2016 16:40:45 +0000 (18:40 +0200)] 
coverity CID 1362013: Control flow issues (NESTING_INDENT_MISMATCH)

9 years agoaf-packet: CentOS6 build fixes 2091/head
Victor Julien [Fri, 20 May 2016 08:41:45 +0000 (10:41 +0200)] 
af-packet: CentOS6 build fixes

9 years agoaf-packet: use time() instead of GetTime()
Eric Leblond [Tue, 26 Apr 2016 17:55:51 +0000 (19:55 +0200)] 
af-packet: use time() instead of GetTime()

As we only use the second we don't need GetTime() which is slower
and get us milliseconds.

9 years agoaf-packet: print errno on mmap error
Eric Leblond [Tue, 26 Apr 2016 17:46:19 +0000 (19:46 +0200)] 
af-packet: print errno on mmap error

9 years agoaf-packet: fix some typos in yaml
Eric Leblond [Fri, 22 Apr 2016 17:50:10 +0000 (19:50 +0200)] 
af-packet: fix some typos in yaml

9 years agoaf-packet: ask for hardware timestamp
Eric Leblond [Fri, 22 Apr 2016 22:30:39 +0000 (00:30 +0200)] 
af-packet: ask for hardware timestamp

9 years agoaf-packet: make mmap options parsing conditional
Eric Leblond [Mon, 18 Apr 2016 12:24:08 +0000 (14:24 +0200)] 
af-packet: make mmap options parsing conditional

Only parse them if mmap is activated.

9 years agoaf-packet: reset stats at start of capture
Eric Leblond [Tue, 12 Apr 2016 09:46:43 +0000 (11:46 +0200)] 
af-packet: reset stats at start of capture

We can loose packets during setup because we are reading nothing.
So it is logical to discard the counter at start of capture to
start from a clean state. This means we don't need to account the
drop at start. But the stats call that will reset the drop counts
will also return and reset the packets count. So we need to know
how many packets we really have. This is in fact the number of
packets coming from the stats call minus the number of discarded
packets and the drop count. All the other packets will have to be
read.

9 years agoaf-packet: use mmap capture by default
Eric Leblond [Fri, 1 Apr 2016 12:01:09 +0000 (14:01 +0200)] 
af-packet: use mmap capture by default

Update the code to use mmap capture by default even in unset in
configuration file. mmap capture is now be turned off by using
explicitely 'use-mmap: no' in configuration.

9 years agoaf-packet: detect availability of tpacket_v3
Eric Leblond [Sat, 9 Apr 2016 14:07:23 +0000 (16:07 +0200)] 
af-packet: detect availability of tpacket_v3

If TPACKET_V3 is not defined then it is not available and we should
not build anything related to tpacket_v3. This will allow us to
activate it dy default and fallback to v2 if not available.

9 years agoaf-packet: add option to use memory locked mmap
Eric Leblond [Fri, 8 Apr 2016 15:05:55 +0000 (17:05 +0200)] 
af-packet: add option to use memory locked mmap

9 years agoaf-packet: configurable tpacket_v3 block timeout
Eric Leblond [Fri, 8 Apr 2016 13:29:18 +0000 (15:29 +0200)] 
af-packet: configurable tpacket_v3 block timeout

Block timeout defines the maximum filling duration of a block.

9 years agoaf-packet: configurable tpacket_v3 block size
Eric Leblond [Fri, 8 Apr 2016 08:03:52 +0000 (10:03 +0200)] 
af-packet: configurable tpacket_v3 block size

It is used to set the block size in tpacket_v3. It will allow user
to tune the capture depending on his bandwidth.

Default block size value has been updated to a bigger value to
allow more efficient wlak on block.

9 years agoaf-packet: put ring setup in a separate function
Eric Leblond [Thu, 7 Apr 2016 19:58:48 +0000 (21:58 +0200)] 
af-packet: put ring setup in a separate function

9 years agoaf-packet: pack AFPPeer structure
Eric Leblond [Fri, 1 Apr 2016 20:52:37 +0000 (22:52 +0200)] 
af-packet: pack AFPPeer structure

9 years agoaf-packet: AFPWalkBlock error handling
Eric Leblond [Fri, 22 Apr 2016 20:15:53 +0000 (22:15 +0200)] 
af-packet: AFPWalkBlock error handling

Error handling was not done. The implementation is making the
choice to consider we must detroy the socket in case of parsing
error. The same was done for tpacket_v2.

9 years agoaf-packet: continuing cleaning and hole hunting
Eric Leblond [Fri, 1 Apr 2016 20:33:22 +0000 (22:33 +0200)] 
af-packet: continuing cleaning and hole hunting

Suppress useless fields in AFPThreadVars. This patch also get rid
of bytes counter as it was only used to display a message at exit.
Information on livedev and on packet counters are enough.

9 years agoaf-packet: cleaning and hole hunting
Eric Leblond [Fri, 1 Apr 2016 17:46:41 +0000 (19:46 +0200)] 
af-packet: cleaning and hole hunting

Reorder fields in AFPThreadVars and suppress some that were not
used elsewhere than in the initialization.

9 years agoaf-packet: tpacket_v3 implementation
Eric Leblond [Mon, 28 Oct 2013 16:19:31 +0000 (17:19 +0100)] 
af-packet: tpacket_v3 implementation

This patch adds a basic implementation of AF_PACKET tpacket v3. It
is basic in the way it is only working for 'workers' runnning mode.
If not in 'workers' mode there is a fallback to tpacket_v2. Feature
is activated via tpacket-v3 option in the af-packet section of
Suricata YAML.

9 years agoaf-packet: remove useless code
Eric Leblond [Fri, 1 Apr 2016 11:52:24 +0000 (13:52 +0200)] 
af-packet: remove useless code

No need for cooked header in the case of mmap capture.

9 years agoaf-packet: micro optimization
Eric Leblond [Fri, 1 Apr 2016 06:48:31 +0000 (08:48 +0200)] 
af-packet: micro optimization

9 years agoaf-packet: avoid test for each packet
Eric Leblond [Thu, 3 Jan 2013 19:29:54 +0000 (20:29 +0100)] 
af-packet: avoid test for each packet

9 years agospm: handle null ptrs in destroy funcs gracefully
Justin Viiret [Fri, 20 May 2016 03:31:05 +0000 (13:31 +1000)] 
spm: handle null ptrs in destroy funcs gracefully

This will handle minimal DetectEngineCtx structures (used in delayed
detect mode) safely, since they don't get SPM global contexts allocated.

Also added BUG_ON checks for valid spm_table entries.

9 years agofile: switch to streaming buffer API
Victor Julien [Mon, 30 Nov 2015 20:21:50 +0000 (21:21 +0100)] 
file: switch to streaming buffer API

Make the file storage use the streaming buffer API.

As the individual file chunks were not needed by themselves, this
approach uses a chunkless implementation.

9 years agohttp: improve body inspection
Victor Julien [Mon, 16 Nov 2015 09:05:56 +0000 (10:05 +0100)] 
http: improve body inspection

Enforce inspect window also in IDS mode. Try always to get at least
'inspect win' worth of data. In case there is more new data, take
some of the old data as well to make sure there is always some overlap.

This unifies IDS and IPS modes, the only difference left is the start
of inspection. IDS waits until min_size is available, IPS starts right
away.

9 years agohttp: make htpstate cfg ptr const
Victor Julien [Sun, 15 Nov 2015 12:21:59 +0000 (13:21 +0100)] 
http: make htpstate cfg ptr const

9 years agohttp: move body settings into per dir struct
Victor Julien [Sun, 15 Nov 2015 12:20:14 +0000 (13:20 +0100)] 
http: move body settings into per dir struct

9 years agohttp: add per direction config for body parsing
Victor Julien [Fri, 13 Nov 2015 23:14:02 +0000 (00:14 +0100)] 
http: add per direction config for body parsing

The HTPCfgDir structure is meant to contain config for per direction
body parsing parameters.

This patch stores the streaming API config.

9 years agohttp body handling: use streaming buffer API
Victor Julien [Wed, 11 Nov 2015 23:19:52 +0000 (00:19 +0100)] 
http body handling: use streaming buffer API

Convert HTTP body handling to use the Streaming Buffer API. This means
the HtpBodyChunks no longer maintain their own data segments, but
instead add their data to the StreamingBuffer instance in the HtpBody
structure.

In case the HtpBodyChunk needs to access it's data it can do so still
through the Streaming Buffer API.

Updates & simplifies the various users of the reassembled bodies:
multipart parsing and the detection engine.

9 years agostreaming: buffer API
Victor Julien [Sun, 8 Nov 2015 17:30:05 +0000 (18:30 +0100)] 
streaming: buffer API

Add a new API to store data from streaming sources, like HTTP body
processing or TCP data.

Currently most of the code uses a pattern of list of data chunks
(e.g. TcpSegment) that is reassembled into a large buffer on-demand.

The Streaming Buffer API changes the logic to store the data in
reassembled form from the start, with the segments/chunks pointing
to the reassembled data.

The main buffer storing the data slides forward, automatically or
manually. The *NoTrack calls allows for a segmentless mode of
operation.

This approach has two main advantages:

1. accessing the reassembled data is virtually cost-free
2. reduction of allocations and memory management

9 years agoautofp: update queue handlers 2089/head
Victor Julien [Tue, 17 May 2016 16:34:55 +0000 (18:34 +0200)] 
autofp: update queue handlers

Now that the flow lookup is done in the worker threads the flow
queue handlers running after the capture thread(s) no longer have
access to the flow. This limits the options of how flow balancing
can be done.

This patch removes all code that is now useless. The only 2 methods
that still make sense are 'hash' and 'ippair'.

9 years agoflow: remove dead code
Victor Julien [Tue, 17 May 2016 16:05:26 +0000 (18:05 +0200)] 
flow: remove dead code

9 years agoflowworker: initial support
Victor Julien [Tue, 19 Apr 2016 16:06:32 +0000 (18:06 +0200)] 
flowworker: initial support

Initial version of the 'FlowWorker' thread module. This module
combines Flow handling, TCP handling, App layer handling and
Detection in a single module. It does all flow related processing
under a single flow lock.

9 years agodetect: simplify flow locking
Victor Julien [Sat, 16 Apr 2016 21:06:33 +0000 (23:06 +0200)] 
detect: simplify flow locking

To simplify locking, move all locking out of the individual detect
code. Instead at the start of detection lock the flow, and at the
end of detection unlock it.

The lua code can be called without a lock still (from the output
code paths), so still pass around a lock hint to take care of this.

9 years agotime: improve offline time handling
Victor Julien [Mon, 18 Apr 2016 13:09:13 +0000 (15:09 +0200)] 
time: improve offline time handling

When we run on live traffic, time handling is simple. Packets have a
timestamp set by the capture method. Management threads can simply
use 'gettimeofday' to know the current time. There should never be
any serious gap between the two or major differnces between the
threads.

In offline mode, things are dramatically different. Here we try to keep
the time from the pcap, which means that if the packets are recorded in
2011 the log output should also reflect this. Multiple issues:

 1. merged pcaps might have huge time jumps or time going backward
 2. slowly recorded pcaps may be processed much faster than their
    'realtime'
 3. management threads need a concept of what the 'current' time is for
    enforcing timeouts
 4. due to (1) individual threads may have very different views on what
    the current time is. E.g. T1 processed packet 1 with TS X, while T2
    at the very same time processes packet 2 with TS X+100000s.

The changes in flow handling make the problems worse. The capture thread
no longer handles the flow lookup, while it did set the global 'time'.
This meant that a thread may be working on Packet 1 with TS 1, while the
capture thread already saw packet 2 with TS 10000. Management threads
would take TS 10000 as the 'current time', considering a flow created by
the first thread as timed out immediately.

This was less of a problem before the flow changes as the capture thread
would also create a flow reference for a packet, meaning the flow
couldn't time out as easily. Packets in the queues between capture
thread and workers would all hold such references.

The patch updates the time handling to be as follows.

In offline mode we keep the timestamp per thread. If a management thread
needs current time, it will get the minimum of the threads' values. This
is to avoid the problem that T2s time value might already trigger a flow
timeout as the flow lastts + 100000s is almost certainly meaning the
flow would be considered timed out.

9 years agoflow: move flow handling into worker threads
Victor Julien [Fri, 15 Apr 2016 15:08:50 +0000 (17:08 +0200)] 
flow: move flow handling into worker threads

Instead of handling the packet update during flow lookup, handle
it in the stream/detect threads. This lowers the load of the
capture thread(s) in autofp mode.

The decoders now set a flag in the packet if the packet needs a
flow lookup. Then the workers will take care of this. The decoders
also already calculate the raw flow hash value. This is so that
this value can be used in flow balancing in autofp.

Because the flow lookup/creation is now done in the worker threads,
the flow balancing can no longer use the flow. It's not yet
available. Autofp load balancing uses raw hash values instead.

In the same line, move UDP AppLayer out of the DecodeUDP module,
and also into the stream/detect threads.

Handle TCP session reuse inside the flow engine itself. If a looked up
flow matches the packet, but is a TCP stream starter, check if the
ssn needs to be reused. If that is the case handle it within the
lookup function. Simplies the locking and removes potential race
conditions.

9 years agoflow: get flow reference during lookup
Victor Julien [Tue, 17 Mar 2015 11:48:14 +0000 (12:48 +0100)] 
flow: get flow reference during lookup

Update Flow lookup functions to get a flow reference during lookup.

This reference is set under the FlowBucket lock.

This paves the way to not getting a flow lock during lookups.

9 years agodetect: split detect entry into flow/noflow
Victor Julien [Sat, 16 Apr 2016 19:30:32 +0000 (21:30 +0200)] 
detect: split detect entry into flow/noflow

This is a preparation for flow locking updates.

9 years agodetect: add (mpm) keyword for tls_sni
Mats Klepsland [Wed, 18 May 2016 11:49:47 +0000 (13:49 +0200)] 
detect: add (mpm) keyword for tls_sni

Match on server name indication (SNI) extension in TLS using tls_sni
keyword, e.g:

alert tls any any -> any any (msg:"SNI test"; tls_sni;
        content:"example.com"; sid:12345;)

9 years agotypo: SURCATA -> SURICATA 2086/head
Jason Ish [Tue, 17 May 2016 19:40:43 +0000 (13:40 -0600)] 
typo: SURCATA -> SURICATA