]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
10 years agodetect: fix small memory leaks 1305/head
Victor Julien [Wed, 21 Jan 2015 10:43:58 +0000 (11:43 +0100)] 
detect: fix small memory leaks

Fix small memory leaks in option parsing. Move away from
pcre_get_substring in favor of pcre_copy_substring.

Related to #1046.

10 years agoClean up Conf API memory on shutdown.
Victor Julien [Wed, 21 Jan 2015 10:31:15 +0000 (11:31 +0100)] 
Clean up Conf API memory on shutdown.

10 years agoFix live reload detect counter setup
Victor Julien [Sun, 18 Jan 2015 09:54:57 +0000 (10:54 +0100)] 
Fix live reload detect counter setup

When profiling was compiled in the detect counters were not setup
properly after a reload.

10 years agoconf api: use const pointers where possible
Victor Julien [Tue, 13 Jan 2015 09:46:56 +0000 (10:46 +0100)] 
conf api: use const pointers where possible

Use const pointers where possible in the Conf API.

10 years agoCosmetic fixes to main()
Victor Julien [Fri, 16 Jan 2015 21:00:28 +0000 (22:00 +0100)] 
Cosmetic fixes to main()

10 years agoSuppress debug statements 1299/head
Victor Julien [Sat, 17 Jan 2015 12:38:44 +0000 (13:38 +0100)] 
Suppress debug statements

10 years agodetect: properly size det_ctx::non_mpm_id_array
Victor Julien [Sat, 17 Jan 2015 10:54:38 +0000 (11:54 +0100)] 
detect: properly size det_ctx::non_mpm_id_array

Track which sgh has the higest non-mpm sig count and use that value
to size the det_ctx::non_mpm_id_array array.

10 years agoFix live reload detect thread ctx setup
Victor Julien [Sat, 17 Jan 2015 09:57:02 +0000 (10:57 +0100)] 
Fix live reload detect thread ctx setup

Code failed to setup non_mpm_id_array in case of a live reload.

10 years agoAC: fix memory leak 1295/head
Victor Julien [Wed, 10 Dec 2014 09:54:22 +0000 (10:54 +0100)] 
AC: fix memory leak

10 years agogeoip: adapt to 'const' pointer passing
Victor Julien [Wed, 10 Dec 2014 09:29:48 +0000 (10:29 +0100)] 
geoip: adapt to 'const' pointer passing

10 years agodetect: expand mask checking
Victor Julien [Sat, 8 Nov 2014 13:02:26 +0000 (14:02 +0100)] 
detect: expand mask checking

Change mask to u16, and add checks for various protocol states
that need to be present for a rule to be considered.

10 years agodetect: introduce DetectPrefilterBuildNonMpmList
Victor Julien [Sat, 8 Nov 2014 12:33:15 +0000 (13:33 +0100)] 
detect: introduce DetectPrefilterBuildNonMpmList

Move building of non-mpm list into a separate function, that is inlined
for performance reasons.

10 years agodetect: add profiling for non-mpm list build & filter
Victor Julien [Sat, 8 Nov 2014 12:23:14 +0000 (13:23 +0100)] 
detect: add profiling for non-mpm list build & filter

10 years agodetect: optimize non-mpm mask checking
Victor Julien [Sat, 8 Nov 2014 11:25:30 +0000 (12:25 +0100)] 
detect: optimize non-mpm mask checking

Store id and mask in a single array of type SignatureNonMpmStore so
that both are loaded into the same cache line.

10 years agodetect: add mask check prefilter for non mpm list
Victor Julien [Fri, 7 Nov 2014 19:57:14 +0000 (20:57 +0100)] 
detect: add mask check prefilter for non mpm list

Add mask array for non_mpm sigs, so that we can exclude many sigs before
we merge sort.

Shows 50% less non mpm sigs inspected on average.

10 years agoConditionalize SigMatch performance counters.
Ken Steele [Fri, 7 Nov 2014 17:46:46 +0000 (12:46 -0500)] 
Conditionalize SigMatch performance counters.

Only include the counters when PROFILING.

10 years agoDetect perf counters
Victor Julien [Thu, 6 Nov 2014 15:05:57 +0000 (16:05 +0100)] 
Detect perf counters

10 years agodetect: Disable unused SignatureHeader code
Victor Julien [Mon, 8 Dec 2014 13:30:52 +0000 (14:30 +0100)] 
detect: Disable unused SignatureHeader code

10 years agoRemove sgh->mask_array
Ken Steele [Fri, 10 Oct 2014 21:13:08 +0000 (17:13 -0400)] 
Remove sgh->mask_array

Not needed by new MPM opt.

10 years agoIndentation clean up
Ken Steele [Mon, 3 Nov 2014 16:50:35 +0000 (11:50 -0500)] 
Indentation clean up

10 years agoFurther optimize merging mpm and non-mpm rule ID lists.
Ken Steele [Mon, 3 Nov 2014 03:27:07 +0000 (22:27 -0500)] 
Further optimize merging mpm and non-mpm rule ID lists.

When reaching the end of either list, merging is no longer required,
simply walk down the other list.

If the non-MPM list can't have duplicates, it would be worth removing
the duplicate check for the non-MPM list when it is the only non-empty list
remaining.

10 years agoCustom Quick Sort for Signature IDs
Ken Steele [Sun, 2 Nov 2014 23:49:54 +0000 (18:49 -0500)] 
Custom Quick Sort for Signature IDs

Use an in place Quick Sort instead of qsort(), which does merge sort and
calls memcpy().

Improves performance on my tests.

10 years agoUse SigIntId as the type for storing signature IDs (Internal)
Ken Steele [Sun, 2 Nov 2014 19:12:16 +0000 (14:12 -0500)] 
Use SigIntId as the type for storing signature IDs (Internal)

Previously using uint32_t, but SigIntId is currently uint16_t, so arrays
will take less memory.

10 years agoIncrease max pattern ID allowed in MPM AC-tile to 28-bits
Ken Steele [Fri, 17 Oct 2014 21:25:30 +0000 (17:25 -0400)] 
Increase max pattern ID allowed in MPM AC-tile to 28-bits

10 years agoClean up sm_array memory at SigFree
Victor Julien [Mon, 8 Dec 2014 11:11:15 +0000 (12:11 +0100)] 
Clean up sm_array memory at SigFree

10 years agoCreate optimized sig_arrays from sig_lists
Ken Steele [Tue, 14 Oct 2014 21:24:14 +0000 (17:24 -0400)] 
Create optimized sig_arrays from sig_lists

Create a copy of the SigMatch data in the sig_lists linked-lists and store
it in an array for faster access and not next and previous pointers. The
array is then used when calling the Match() functions.

Gives a 7.7% speed up on one test.

10 years agoChange Match() function to take const SigMatchCtx*
Ken Steele [Tue, 14 Oct 2014 20:08:59 +0000 (16:08 -0400)] 
Change Match() function to take const SigMatchCtx*

The Match functions don't need a pointer to the SigMatch object, just the
context pointer contained inside, so pass the Context to the Match function
rather than the SigMatch object. This allows for further optimization.

Change SigMatch->ctx to have type SigMatchCtx* rather than void* for better
type checking. This requires adding type casts when using or assigning it.

The SigMatch contex should not be changed by the Match() funciton, so pass it
as a const SigMatchCtx*.

10 years agoCreate Specialized SCMemcmpNZ() when the length can't be zero.
Ken Steele [Mon, 13 Oct 2014 18:36:45 +0000 (14:36 -0400)] 
Create Specialized SCMemcmpNZ() when the length can't be zero.

10 years agoReplace memcpy() in MpmAddSids with copy loop
Ken Steele [Fri, 10 Oct 2014 17:55:55 +0000 (13:55 -0400)] 
Replace memcpy() in MpmAddSids with copy loop

For the short size of most sids lists, a straight copy loop is faster.

10 years agoFix compiler warnings in ac-tile.
Ken Steele [Fri, 10 Oct 2014 14:34:48 +0000 (10:34 -0400)] 
Fix compiler warnings in ac-tile.

Signed vs unsigned comparisons.

10 years agoPrefetch the next signature pointer
Ken Steele [Mon, 6 Oct 2014 14:00:36 +0000 (10:00 -0400)] 
Prefetch the next signature pointer

Read one signature pointer ahead to prefetch the value.
Use a variable, sflags, for s->flags, since it is used many times and the
compiles doesn't know that the signatures structure doesn't change, so it
will reload s->flags.

10 years agoMove type first in SigMatch array since it is used more often.
Ken Steele [Fri, 5 Sep 2014 21:21:28 +0000 (17:21 -0400)] 
Move type first in SigMatch array since it is used more often.

10 years agoIn AC-Tile, convert from using pids for indexing to pattern index
Ken Steele [Fri, 3 Oct 2014 21:12:06 +0000 (17:12 -0400)] 
In AC-Tile, convert from using pids for indexing to pattern index

Use an MPM specific pattern index, which is simply an index starting
at zero and incremented for each pattern added to the MPM, rather than
the externally provided Pattern ID (pid), since that can be much
larger than the number of patterns. The Pattern ID is shared across at
MPMs. For example, an MPM with one pattern with pid=8000 would result
in a max_pid of 8000, so the pid_pat_list would have 8000 entries.

The pid_pat_list[] is replaced by a array of pattern indexes. The PID is
moved to the SCACTilePatternList as a single value. The PatternList is
also indexed by the Pattern Index.

max_pat_id is no longer needed and mpm_ctx->pattern_cnt is used instead.

The local bitarray is then also indexed by pattern index instead of PID, making
it much smaller. The local bit array sets a bit for each pattern found
for this MPM. It is only kept during one MPM search (stack allocated).

One note, the local bit array is checked first and if the pattern has already
been found, it will stop checking, but count a match. This could result in
over counting matches of case-sensitve matches, since following case-insensitive
matches will also be counted. For example, finding "Foo" in "foo Foo foo" would
report finding "Foo" 2 times, mis-counting the third word as "Foo".

10 years agoFix missing use of MpmAddPid()
Ken Steele [Mon, 17 Nov 2014 15:24:27 +0000 (10:24 -0500)] 
Fix missing use of MpmAddPid()

Found by Victor using ASAN. One place was not checking to resize the
pid array before adding a new PID.

10 years agofix check in PmqMerge
Ken Steele [Fri, 7 Nov 2014 15:52:08 +0000 (10:52 -0500)] 
fix check in PmqMerge

10 years agoFix bug in MPM rule array handling
Ken Steele [Thu, 6 Nov 2014 19:57:53 +0000 (14:57 -0500)] 
Fix bug in MPM rule array handling

In PmqMerge() use MpmAddSids() instead of blindly copying the src
rule list onto the end of the dst rule list, since there might not
be enough room in the dst list. MpmAddSids() will resize the dst array
if needed.

Also add code to MpmAddSids() MpmAddPid() to better handle the case
that realloc fails to get more space. It first tries 2x the needed
space, but if that fails, it tries for just 1x. If that fails resize
returns 0. For MpmAddPid(), if resize fails, the new pid is lost. For
MpmAddSids(), as many SIDs as will fit are added, but some will be
lost.

10 years agoDynamically resize pattern id array as needed
Ken Steele [Wed, 8 Oct 2014 18:36:29 +0000 (14:36 -0400)] 
Dynamically resize pattern id array as needed

Rather than creating the array of size maxpatid, dynamically resize as needed.
This also handles the case where duplicate pid are added to the array.

Also fix error in bitarray allocation (local version) to always use bitarray_size.

10 years agoDynamically resize pmq->rule_id_array
Ken Steele [Fri, 3 Oct 2014 17:30:57 +0000 (13:30 -0400)] 
Dynamically resize pmq->rule_id_array

Rather than statically allocate 64K entries in every rule_id_array,
increase the size only when needed. Created a new function MpmAddSids()
to check the size before adding the new sids. If the array is not large
enough, it calls MpmAddSidsResize() that calls realloc and does error
checking. If the realloc fails, it prints an error and drops the new sids
on the floor, which seems better than exiting Suricata.

The size is increased to (current_size + new_count) * 2. This handles the
case where new_count > current_size, which would not be handled by simply
using current_size * 2. It should also be faster than simply reallocing to
current_size + new_count, which would then require another realloc for each
new addition.

10 years agoFix clang warning
Ken Steele [Tue, 30 Sep 2014 17:04:27 +0000 (13:04 -0400)] 
Fix clang warning

Clang doesn't seem to like defining a function within a function.

10 years agoOptimize DetectPrefilterMergeSort
Ken Steele [Fri, 31 Oct 2014 17:22:55 +0000 (13:22 -0400)] 
Optimize DetectPrefilterMergeSort

Fixup rebase changes to remove debug code

10 years agoImplement MPM opt for ac-bs and ac-gfbs
Ken Steele [Wed, 1 Oct 2014 21:13:54 +0000 (17:13 -0400)] 
Implement MPM opt for ac-bs and ac-gfbs

Copies sids changes from ac.

10 years agoImplement MPM opt for b2g, b3g, wumanber
Ken Steele [Tue, 30 Sep 2014 14:58:35 +0000 (10:58 -0400)] 
Implement MPM opt for b2g, b3g, wumanber

Found problems in b2gm and b2gc, so those are removed.

10 years agoFix AC-tile for new pattern ID array.
Ken Steele [Wed, 3 Sep 2014 13:17:45 +0000 (09:17 -0400)] 
Fix AC-tile for new pattern ID array.

10 years agoAC: use local bit array
Victor Julien [Tue, 19 Aug 2014 13:09:59 +0000 (15:09 +0200)] 
AC: use local bit array

Use a local pattern bit array to making sure we don't match more than
once, in addition to the pmq bitarray that is still used for results
validation higher up in the rule matching process.

Why: pmq->pattern_id_bitarray is currently sometimes used in a
'stateful' way, meaning that for a single packet we run multiple
MPM's on the same pmq w/o resetting it.

The new bitarray is used to determine wherther we need to append the
patterns associated 'sids' list to the pmq rule_id_array.

It has been observed that MPM1 matches for PAT1, and MPM2 matches for
PAT1 as well. However, in MPM1 PAT1 doesn't have the same sids list.
In this case MPM2 would not add it's sids to the list, leading to missed
detection.

10 years agodetect: move checks from prefilter to rule detect
Victor Julien [Tue, 19 Aug 2014 13:02:49 +0000 (15:02 +0200)] 
detect: move checks from prefilter to rule detect

Move the prefilter checks to the main detect loop.

10 years agoReplace build match array with new filter logic
Victor Julien [Mon, 18 Aug 2014 14:05:49 +0000 (16:05 +0200)] 
Replace build match array with new filter logic

Use MPM and non-MPM lists to build our match array. Both lists are
sorted, and are merged and sorted into the match array.

This disables the old match array building code and thus also bypasses
the mask checking.

10 years agodetect: Add negated MPM to non-MPM array
Victor Julien [Mon, 18 Aug 2014 14:05:16 +0000 (16:05 +0200)] 
detect: Add negated MPM to non-MPM array

Treat negated MPM sigs as if non-MPM, so we consider them always.

As MPM results and non-MPM rules lists are now merged and considered
for further inspection, rules that need to be considerd when a pattern
is absent are caught in the middle.

As a HACK/workaround this patch adds them to the non-MPM list. This
causes them to be inspected each time.

10 years agoDetect: create per sgh non-MPM rule array
Victor Julien [Mon, 18 Aug 2014 11:51:40 +0000 (13:51 +0200)] 
Detect: create per sgh non-MPM rule array

Array of rule id's that are not using MPM prefiltering. These will be
merged with the MPM results array. Together these should lead to a
list of all the rules that can possibly match.

10 years agoMPM: build sid list from MPM matches
Victor Julien [Mon, 18 Aug 2014 11:19:07 +0000 (13:19 +0200)] 
MPM: build sid list from MPM matches

Pmq add rule list: Array of uint32_t's to store (internal) sids from the MPM.

AC: store sids in the pattern list, append to Pmq::rule_id_array on match.

Detect: sort rule_id_array after it was set up by the MPM. Rule id's
(Signature::num) are ordered, and the rule's with the lowest id are to
be inspected first. As the MPM doesn't fill the array in order, but instead
'randomly' we need this sort step to assure proper inspection order.

10 years agoCreate a wrapper around DetectFlowvarProcessList() to check for empty list
Ken Steele [Fri, 5 Sep 2014 21:14:34 +0000 (17:14 -0400)] 
Create a wrapper around DetectFlowvarProcessList() to check for empty list

Creates an inline wrapper to check for flowvarlist == NULL before calling
DetectFlowvarProcessList() to remove the overhead of checking since the
list is usually empty.

10 years agoRemove the b2gm and b2gc MPMs
Ken Steele [Thu, 16 Oct 2014 12:19:25 +0000 (08:19 -0400)] 
Remove the b2gm and b2gc MPMs

These MPMs have code that looks like it won't work and updating them to
for the new MPM optimization wasn't working.

10 years agoGlobal define of MIN
Victor Julien [Mon, 8 Dec 2014 09:40:17 +0000 (10:40 +0100)] 
Global define of MIN

Some OS' provide it automatically, so make sure we define it
conditionally in one place.

10 years agoFix a fix: defrag OOM condition 1294/head
Victor Julien [Fri, 12 Dec 2014 17:20:24 +0000 (18:20 +0100)] 
Fix a fix: defrag OOM condition

** CID 1257764:  Dereference after null check  (FORWARD_NULL)
/src/defrag.c: 291 in Defrag4Reassemble()

** CID 1257763:  Dereference after null check  (FORWARD_NULL)
/src/defrag.c: 409 in Defrag6Reassemble()

In the error case 'rp' can be both NULL or non-NULL.

10 years agodetect: add test for memcmp issue
Victor Julien [Wed, 17 Dec 2014 09:30:34 +0000 (10:30 +0100)] 
detect: add test for memcmp issue

10 years agoAdd test for memcmp issue.
Victor Julien [Tue, 16 Dec 2014 18:41:32 +0000 (19:41 +0100)] 
Add test for memcmp issue.

10 years agomemcmp: compare the first byte as well
Victor Julien [Tue, 16 Dec 2014 18:12:20 +0000 (19:12 +0100)] 
memcmp: compare the first byte as well

MemcmpLowercase would not compare the first byte of both input buffers
leading to two non-identical buffers to be considered the same.

Affects SSE_4_1 and SSE_4_2 implementations of SCMemcmpLowercase, as well
as the non-SIMD implementation. SSE_3 and Tile version are not affected.

10 years agoFix OS X 10.10 unittest failure
Victor Julien [Wed, 14 Jan 2015 22:49:54 +0000 (23:49 +0100)] 
Fix OS X 10.10 unittest failure

Work around OS X 10.10 Yosemite returning EDEADLK on a rwlock wrlocked
then tested by wrtrylock. All other OS' (and versions of OS X that I
tested) seem to return EBUSY instead.

10 years agoFix Tilera compilation
Victor Julien [Wed, 14 Jan 2015 20:55:31 +0000 (21:55 +0100)] 
Fix Tilera compilation

Use proper initializer for a static mutex declaration.

Credits: Ken Steele

10 years agoFix compilation on OS X Yosemite 1293/head
Victor Julien [Wed, 14 Jan 2015 08:48:39 +0000 (09:48 +0100)] 
Fix compilation on OS X Yosemite

Due to our unconditional declaration of the strlcat and strlcpy
functions, compilation failed on OS X Yosemite.

Bug #1192

10 years agoUpdate reference.config 1289/head
Travis Green [Tue, 23 Dec 2014 22:10:21 +0000 (15:10 -0700)] 
Update reference.config

Updated reference.config to match ET Open reference.config found here:
https://rules.emergingthreats.net/open/suricata/reference.config

Due to startup error shown here:
root@xxxxxxx01:/etc/suricata/rules# /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /var/run/suricata.pid --af-packet
23/12/2014 -- 22:07:56 - <Error> - [ERRCODE: SC_ERR_REFERENCE_UNKNOWN(150)] - unknown reference key "osvdb". Supported keys are defined in reference.config file.  Please have a look at the conf param "reference-config-file"
<...>
Killed

10 years agoRespect DESTDIR in install-conf and install-rules.
Jason Ish [Mon, 29 Dec 2014 16:04:37 +0000 (10:04 -0600)] 
Respect DESTDIR in install-conf and install-rules.

10 years agounix socket: support profiling
Victor Julien [Tue, 6 Jan 2015 12:11:38 +0000 (13:11 +0100)] 
unix socket: support profiling

10 years agosmtp: fix tx handling
Victor Julien [Mon, 5 Jan 2015 12:17:51 +0000 (13:17 +0100)] 
smtp: fix tx handling

Fix issue where SMTPStateGetTxCnt would return the actual active tx'.

The 'GetCnt' API call is not named correctly. It should be 'GetMaxId',
as this is actually the expected behavior.

10 years agothread local storage: add to build-info
Victor Julien [Tue, 6 Jan 2015 12:20:55 +0000 (13:20 +0100)] 
thread local storage: add to build-info

10 years agopacket pool: make pending pool use more robust 1286/head
Victor Julien [Tue, 6 Jan 2015 09:22:37 +0000 (10:22 +0100)] 
packet pool: make pending pool use more robust

Don't leave pointers dangling.

10 years agopacket pool: memory fixes for non-TLS
Victor Julien [Tue, 6 Jan 2015 09:20:40 +0000 (10:20 +0100)] 
packet pool: memory fixes for non-TLS

If the posix TLS implementation is used, the packet pool is memset to
0 before use.

Also use proper 'free' function.

10 years agoconfigure: add switch to disable __thread use
Victor Julien [Tue, 6 Jan 2015 09:18:38 +0000 (10:18 +0100)] 
configure: add switch to disable __thread use

Add --disable-threading-tls switch to force the posix thread local
storage code paths even if __thread is available.

Goal is to make it easier to QA the posix code path.

10 years agopacket pool: fix wrong free call
Victor Julien [Mon, 5 Jan 2015 16:42:28 +0000 (17:42 +0100)] 
packet pool: fix wrong free call

10 years agoapp-layer: fix 'detection-only' keyword 1279/head
Eric Leblond [Fri, 19 Dec 2014 14:06:30 +0000 (15:06 +0100)] 
app-layer: fix 'detection-only' keyword

If we follow the description in the yaml file, we should disable
parsing if 'detection-only' keyword is used.

10 years agooutput-json: fix duplicate logging
Eric Leblond [Mon, 15 Dec 2014 23:14:59 +0000 (00:14 +0100)] 
output-json: fix duplicate logging

This patches is fixing a issue in the OutputJSONBuffer function. It
was writing to file the content of the buffer starting from the start
to the final offset. But as the writing is done for each JSON string
we are duplicating the previous events if we are reusing the same
buffer.

Duplication was for example triggered when we have multiple alerts
attached to a packet. In the case of two alerts, the first one was
logged twice more as the second one.

10 years agostream: improve inline mode GAP handling
Victor Julien [Tue, 9 Dec 2014 12:37:54 +0000 (13:37 +0100)] 
stream: improve inline mode GAP handling

Don't conclude a GAP is 'final' until the missing data is ack'd.

Further, cleanup and unify more with the non-inline code.

10 years agostream: move utility functions
Victor Julien [Tue, 9 Dec 2014 11:55:19 +0000 (12:55 +0100)] 
stream: move utility functions

This way they can be used by the *Inline* functions as well.

10 years agohost: register unittests
Victor Julien [Fri, 19 Dec 2014 09:16:49 +0000 (10:16 +0100)] 
host: register unittests

Host unittests were not registered so they wouldn't run.

10 years agopacket-pool: free pending packets 1277/head
Victor Julien [Mon, 22 Dec 2014 16:00:56 +0000 (17:00 +0100)] 
packet-pool: free pending packets

10 years agostats: stats threads don't need packet pools
Victor Julien [Mon, 22 Dec 2014 12:15:08 +0000 (13:15 +0100)] 
stats: stats threads don't need packet pools

10 years agoflow manager: destroy packet pool on close
Victor Julien [Mon, 22 Dec 2014 12:10:53 +0000 (13:10 +0100)] 
flow manager: destroy packet pool on close

10 years agoflow-timeout: use packet pool 1272/head
Victor Julien [Wed, 17 Dec 2014 16:15:38 +0000 (17:15 +0100)] 
flow-timeout: use packet pool

Use packet pool for pseudo packets on flow timeout. Wait for a packet
if necessary.

For shutdown, alloc a new pool as the 'main()' thread calls this.

10 years agothreading: lock TmThreadKillThreadsFamily
Victor Julien [Wed, 17 Dec 2014 14:50:29 +0000 (15:50 +0100)] 
threading: lock TmThreadKillThreadsFamily

10 years agoflow timeout: cleanups
Victor Julien [Wed, 10 Dec 2014 15:41:03 +0000 (16:41 +0100)] 
flow timeout: cleanups

Rename FlowForceReassemblyForFlowV2 to just FlowForceReassemblyForFlow
as there is no V1.

10 years agoflow timeout: cleanup
Victor Julien [Tue, 2 Dec 2014 16:40:31 +0000 (17:40 +0100)] 
flow timeout: cleanup

Remove now unused old flow timeout code.

10 years agostream: handle flow timeout stream end packets
Victor Julien [Tue, 2 Dec 2014 09:02:27 +0000 (10:02 +0100)] 
stream: handle flow timeout stream end packets

Handle flow timeout packets in the stream engine. Previously the flow
timeout code would call reassembly code directly.

10 years agoflow-time: disable remainder of the old timeout code
Victor Julien [Mon, 1 Dec 2014 18:18:45 +0000 (19:18 +0100)] 
flow-time: disable remainder of the old timeout code

Disable registration code that was looking for threadvars
and slots as timeout handling is now done in a live engine.

10 years agoflow-time: use live threads at shutdown
Victor Julien [Mon, 1 Dec 2014 17:48:03 +0000 (18:48 +0100)] 
flow-time: use live threads at shutdown

Update pktacq loop to process flow timeouts in a running engine.

Add a new step to the shutdown phase of packet acquisition loop
threads (pktacqloop).

The shutdown code lets the pktacqloop break out of it's packet
acquisition loop. The thread then enters a flow timeout loop, where
it processes packets from it's tv->stream_pq queue until it's
empty _and_ the KILL flag is set.

Make sure receive threads are done before moving on to flow hash
cleanup (recycle all). Without this the flow recycler could start
it's unconditional hash clean up while detect threads are still
running on the flows.

Update unix socket to match live modes.

10 years agoflow-timeout: use live threads
Victor Julien [Mon, 1 Dec 2014 12:53:30 +0000 (13:53 +0100)] 
flow-timeout: use live threads

Use live threads. Disable old timeout code.

10 years agoAssign thread_id to flow on first packet stream engine
Victor Julien [Tue, 25 Nov 2014 10:50:03 +0000 (11:50 +0100)] 
Assign thread_id to flow on first packet stream engine

10 years agoThread registration: id's start at 1
Victor Julien [Wed, 10 Dec 2014 10:49:30 +0000 (11:49 +0100)] 
Thread registration: id's start at 1

Start thread id's at 1, so that in flow's we can use 0 to indicate
a thread id hasn't been set in it yet.

10 years agoIntroduce Flow timeout injection api
Victor Julien [Tue, 25 Nov 2014 14:52:38 +0000 (15:52 +0100)] 
Introduce Flow timeout injection api

Add function TmThreadsInjectPacketById that is to be used to inject flow
timeout packets into the threads stream_pq queue.

TmThreadsInjectPacketById will also wake up listening threads if
applicable.

Packets are passed all packets together in an NULL terminated array
to reduce locking overhead.

10 years agoDefine FlowThreadId and add it to the flow
Victor Julien [Tue, 25 Nov 2014 10:07:03 +0000 (11:07 +0100)] 
Define FlowThreadId and add it to the flow

16 bits id should be enough for threads for a while.

10 years agoGive easy access for thread stream packet queue
Victor Julien [Tue, 25 Nov 2014 14:05:06 +0000 (15:05 +0100)] 
Give easy access for thread stream packet queue

Access it from ThreadVars. This allows for easy injection of packets
into the stream engine.

10 years agoThread Registration API for ID's
Victor Julien [Mon, 24 Nov 2014 22:17:37 +0000 (23:17 +0100)] 
Thread Registration API for ID's

Create thread registration and unregistration API for assigning unique
thread id's.

Threadvars is static even if a thread restarts, so we can do the
registration before the threads start.

A thread is unregistered when the ThreadVars are freed.

10 years agoFix and improvements
Duarte Silva [Fri, 12 Dec 2014 18:21:24 +0000 (18:21 +0000)] 
Fix and improvements
- Added/removed missing/superfluous util-memrchr.h include
- Improved the extraction of a IP from the XFF chain of IPs

10 years agoImplemented the diferent behaviour depending on the proxy deployment
Duarte Silva [Fri, 5 Dec 2014 15:59:05 +0000 (15:59 +0000)] 
Implemented the diferent behaviour depending on the proxy deployment
- In forward deployment mode the first IP will be returned
- In reverse deployment mode the last IP will be retuned

10 years agoPrepared everything for the proxy deployment configuration
Duarte Silva [Fri, 5 Dec 2014 15:52:16 +0000 (15:52 +0000)] 
Prepared everything for the proxy deployment configuration
- Added the suricata.yaml configurations and updated the comments
- Renamed the field in the configuration structure to something generic
- Added two new constants and the warning codes

10 years agoAdding XFF support to EVE alert output
Duarte Silva [Fri, 5 Dec 2014 15:40:58 +0000 (15:40 +0000)] 
Adding XFF support to EVE alert output
- Created app-layer-htp-xff.c and app-layer-htp-xff.h
- Added entries in the Makefile.am
- Added the necessary configuration options to EVE alert section
- Updated Unified2 XFF configuration comments and removed unnecessary whitespace
- Created a generic function to parse the configuration
- Release the flow locks sooner and remove debug logging
- Added XFF support to EVE alert output

10 years agofix Cygwin build fails: array subscript has type char 1258/head
DIALLO David [Mon, 15 Dec 2014 16:53:34 +0000 (17:53 +0100)] 
fix Cygwin build fails: array subscript has type char

10 years agoAdd a warning in Modbus section of YAML file to remind user to modify stream depth...
DIALLO David [Mon, 15 Dec 2014 16:37:04 +0000 (17:37 +0100)] 
Add a warning in Modbus section of YAML file to remind user to modify stream depth (unlimited)

10 years agoUpdate AppLayerProtoDetectPrintProbingParsers with Modbus protocol
DIALLO David [Mon, 15 Dec 2014 15:51:11 +0000 (16:51 +0100)] 
Update AppLayerProtoDetectPrintProbingParsers with Modbus protocol

10 years agofix CID 1257762: Logically dead code(DEADCODE)
DIALLO David [Mon, 15 Dec 2014 15:45:39 +0000 (16:45 +0100)] 
fix CID 1257762:  Logically dead code(DEADCODE)

10 years agosuricatasc: exit with error if command returns NOK 1252/head
Eric Leblond [Fri, 12 Dec 2014 09:10:46 +0000 (10:10 +0100)] 
suricatasc: exit with error if command returns NOK

10 years agosuricatasc: now python 2 and 3 compatible
Eric Leblond [Thu, 11 Dec 2014 19:01:59 +0000 (20:01 +0100)] 
suricatasc: now python 2 and 3 compatible

Update code to support both python 2 and python 3.