]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
9 years agoapp-layer setup scripts: enable new modules on copy 1699/head
Jason Ish [Thu, 8 Oct 2015 21:20:25 +0000 (15:20 -0600)] 
app-layer setup scripts: enable new modules on copy

The templates are disabled by default, enable the copy
of the template so the new app-layer modules are enabled by
by default.

9 years agotemplate app-layer: disable if not in config file (default)
Jason Ish [Thu, 8 Oct 2015 20:54:57 +0000 (14:54 -0600)] 
template app-layer: disable if not in config file (default)

Unlike other app-layer protocols which are enabled by default,
disable this one by default as it likely shouldn't be enabled
in production use of Suricata.

9 years agojson-email-common: fix email extended logging
Eric Leblond [Wed, 14 Oct 2015 12:17:19 +0000 (14:17 +0200)] 
json-email-common: fix email extended logging

Two structure fields were uninitialized and used has a bit field.
Weird behavior were seen in list of logged fields due to that with
some build options.

9 years agojson-email-common: suppress commented code
Eric Leblond [Wed, 14 Oct 2015 11:48:29 +0000 (13:48 +0200)] 
json-email-common: suppress commented code

9 years agojson-email-common: can now log same header twice
Eric Leblond [Wed, 14 Oct 2015 10:13:06 +0000 (12:13 +0200)] 
json-email-common: can now log same header twice

Multiple events can be applied on a transaction so we may need to
log the same header twice.

The HDR_IS_LOGGED flag was making it impossible. And this system
is usless as email application layer is transaction based.

9 years agoBugfix for detect-engine.luajit-states
Torgeir Natvig [Fri, 16 Oct 2015 22:44:49 +0000 (00:44 +0200)] 
Bugfix for detect-engine.luajit-states

detect-engine is a list, and luajit-states was looked up as a map.

9 years agolua: SSH output support 1677/head
Mats Klepsland [Fri, 2 Oct 2015 07:23:13 +0000 (09:23 +0200)] 
lua: SSH output support

Support SSH in lua output scripts (Feature #1569).

9 years agolua: SSH support
Mats Klepsland [Fri, 2 Oct 2015 07:00:51 +0000 (09:00 +0200)] 
lua: SSH support

Support SSH in lua detection scripts (Feature #1569).

9 years agoDescribe new unified2-alert "payload" option 1675/head
Alessandro Guido [Tue, 8 Sep 2015 09:39:20 +0000 (11:39 +0200)] 
Describe new unified2-alert "payload" option

9 years agoAdd option to omit payload in unified2 output
Alessandro Guido [Fri, 19 Jun 2015 14:57:48 +0000 (16:57 +0200)] 
Add option to omit payload in unified2 output

Add a boolean option named "payload" to the unified2-alert output type.
Such options makes suricata omit the payload in the resulting unified2
file. The default value is true in order to preserve the current behaviour.

9 years agoGPL license sync with official gpl-2.0.txt
Jason Ish [Mon, 21 Sep 2015 21:39:37 +0000 (15:39 -0600)] 
GPL license sync with official gpl-2.0.txt

Synced up with:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

9 years agofix util-host-os-info unit tests.
Jason Ish [Mon, 20 Apr 2015 21:54:11 +0000 (15:54 -0600)] 
fix util-host-os-info unit tests.

- Some tests always passed due to the result value being
  initialized to 1.

- Fix tests that now fail.  Looks like just the test were wrong
  and that the code does the right thing.

9 years agodetect-pcre: allow upper cases metachars for host (/W).
Jason Ish [Tue, 22 Sep 2015 19:58:41 +0000 (13:58 -0600)] 
detect-pcre: allow upper cases metachars for host (/W).

Redmine issue 1490.

9 years agoutil-debug: don't colorize if a redirect is used
Eric Leblond [Thu, 24 Sep 2015 12:20:42 +0000 (14:20 +0200)] 
util-debug: don't colorize if a redirect is used

It is better to disable the color mode when a redirect of stderr
is done to avoid getting colorized output in the generated file.

9 years agodefrag tests: fix compiler warnings
Victor Julien [Thu, 24 Sep 2015 10:24:15 +0000 (12:24 +0200)] 
defrag tests: fix compiler warnings

defrag.c:2423:9: error: variable 'p' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2460:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2423:5: note: remove the 'if' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2423:9: error: variable 'p' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2460:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2423:9: note: remove the '||' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2423:9: error: variable 'p' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~
defrag.c:2460:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2423:9: note: remove the '||' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~
defrag.c:2427:5: note: variable 'p' is declared here
    Packet *p = Defrag(NULL, NULL, p1, NULL);
    ^
defrag.c:2486:9: error: variable 'p' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2523:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2486:5: note: remove the 'if' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2486:9: error: variable 'p' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2523:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2486:9: note: remove the '||' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
defrag.c:2486:9: error: variable 'p' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~
defrag.c:2523:9: note: uninitialized use occurs here
    if (p != NULL) {
        ^
defrag.c:2486:9: note: remove the '||' if its condition is always false
    if (p1 == NULL || p2 == NULL || p3 == NULL) {
        ^~~~~~~~~~~~~
defrag.c:2490:5: note: variable 'p' is declared here
    Packet *p = Defrag(NULL, NULL, p1, NULL);
    ^
6 errors generated.
make[3]: *** [defrag.o] Error 1

9 years agodefrag: stop reassembly at the first packet with more flags not set
Jason Ish [Thu, 27 Aug 2015 19:59:30 +0000 (13:59 -0600)] 
defrag: stop reassembly at the first packet with more flags not set

9 years agodefrag: tracker initialization cleanup
Jason Ish [Mon, 15 Jun 2015 17:14:16 +0000 (11:14 -0600)] 
defrag: tracker initialization cleanup

Remove the old tracker reset macro which is no longer being used.
Clear last_seen and remove flags on initialization.
Remove extra call to DefragTrackerInit as it was being called 2x
for each new tracker.

Now that DefragTrackerNew is just a wrapper for DefragTrackerAlloc,
remove it and just call DefragTrackerAlloc directly.

9 years agodefrag: don't use trackers marked for removal
Jason Ish [Mon, 15 Jun 2015 17:06:50 +0000 (11:06 -0600)] 
defrag: don't use trackers marked for removal

These trackers are likely for completed fragments, but have
not been cleaned up. If a packet on the same flow with an
already seen IP ID is seen, it could be reused prior to
being properly reinitialized.

9 years agodefrag: unit test for tracker reuse (current fails)
Jason Ish [Thu, 18 Jun 2015 20:18:49 +0000 (14:18 -0600)] 
defrag: unit test for tracker reuse (current fails)

Will be fixed in subsequent commits as tracker reuse is fixed.

9 years agounix-manager: log client (dis)connection with DEBUG level.
Alexander Gozman [Sun, 27 Sep 2015 19:03:12 +0000 (22:03 +0300)] 
unix-manager: log client (dis)connection with DEBUG level.

Also select/receive errors are logged as ERROR.

9 years agoFeature 1527: ability to compile as a position independent executable
Alexander Gozman [Mon, 28 Sep 2015 21:08:55 +0000 (00:08 +0300)] 
Feature 1527: ability to compile as a position independent executable

Adds corresponding configure option which enables proper CPPFLAGS
and LDFLAGS.

9 years agolua: TLS lua output support
Mats Klepsland [Wed, 30 Sep 2015 08:42:26 +0000 (10:42 +0200)] 
lua: TLS lua output support

Support TLS in lua output scripts (Feature #1568).

function init (args)
    local needs = {}
    needs["protocol"] = "tls"
    return needs
end

function setup (args)
    filename = SCLogPath() .. "/" .. "lua_tls.log"
    file = assert(io.open(filename, "a"))
end

function log (args)
    ts = SCPacketTimeString()
    ipver, srcip, dstip, proto, sp, dp = SCFlowTuple()

    version, subject, issuer, fingerprint = TlsGetCertInfo();
    if version == nil then
        return 0
    end

    file:write(ts .. " " .. srcip .. ":" .. sp .. " -> " .. dstip  ..
               ":" .. dp .. "  TLS: " .. "Subject='" .. subject ..
               "' " .. "Issuerdn='" .. issuer .. "\n")
    file:flush()
end

function deinit (args)
    file:close(file)
end

9 years agodecode-mime: fix body md5 computation 1671/head
Eric Leblond [Fri, 2 Oct 2015 21:40:54 +0000 (23:40 +0200)] 
decode-mime: fix body md5 computation

Previous code was wrongly supposing the lines are ending with CRLF.
But this is not the case so we must propagate the length of end of
line delimiter to be able to compute the md5 of the mail body.

9 years agoutil-decode-mime: fix some unittests
Eric Leblond [Wed, 23 Sep 2015 12:49:03 +0000 (14:49 +0200)] 
util-decode-mime: fix some unittests

Unittests were failling when ASAN is activated because it was
finding some read outside of bounds. This patch fixes the different
reported issues.

9 years agoutil-decode-mime: fix IsIpv6Host function
Eric Leblond [Wed, 23 Sep 2015 12:47:40 +0000 (14:47 +0200)] 
util-decode-mime: fix IsIpv6Host function

Using in6_addr is better when calling inet_pton. This fixes an
issue reported by ASAN.

9 years agosmtp-layer: remove FIXME and del excessive newline
Eric Leblond [Wed, 23 Sep 2015 11:54:38 +0000 (13:54 +0200)] 
smtp-layer: remove FIXME and del excessive newline

9 years agooutput-json: add tx_id to events
Eric Leblond [Tue, 15 Sep 2015 14:36:37 +0000 (16:36 +0200)] 
output-json: add tx_id to events

This patch updates alert, stmp and http JSON logging to have a
tx_id in the root of the JSON log message.

9 years agooutput-json: add create header with tx function
Eric Leblond [Tue, 15 Sep 2015 14:34:44 +0000 (16:34 +0200)] 
output-json: add create header with tx function

To be able to correlate between events, it is better to have the
tx_id information in the root object. This function adds a new
function to automate the addition of the field.

9 years agojson-email: JsonEmailAddMetadata update
Eric Leblond [Tue, 15 Sep 2015 13:48:19 +0000 (15:48 +0200)] 
json-email: JsonEmailAddMetadata update

Add tx_id to the list of params to be in sync with recent changes.

9 years agojson-http: gen metadata function with tx_id param
Eric Leblond [Tue, 15 Sep 2015 07:36:00 +0000 (09:36 +0200)] 
json-http: gen metadata function with tx_id param

9 years agojson-smtp: add tx_id param to metadata generation
Eric Leblond [Mon, 14 Sep 2015 09:39:19 +0000 (11:39 +0200)] 
json-smtp: add tx_id param to metadata generation

In all metadata generation contexts we know the tx_id so we better
used it to log the correct transaction and not an other one.

9 years agojson-smtp: change copyright date
Eric Leblond [Mon, 14 Sep 2015 09:38:39 +0000 (11:38 +0200)] 
json-smtp: change copyright date

9 years agojson-alert: add smtp elements in alert
Eric Leblond [Sun, 13 Sep 2015 17:08:52 +0000 (19:08 +0200)] 
json-alert: add smtp elements in alert

9 years agojson-smtp: fix a debug message
Eric Leblond [Sun, 13 Sep 2015 17:07:34 +0000 (19:07 +0200)] 
json-smtp: fix a debug message

9 years agoemail-json: add bcc to extended fields
Eric Leblond [Wed, 20 May 2015 08:23:36 +0000 (10:23 +0200)] 
email-json: add bcc to extended fields

9 years agosmtp-layer: add MAIL FROM parsing test in unittest
Eric Leblond [Tue, 12 May 2015 15:56:59 +0000 (17:56 +0200)] 
smtp-layer: add MAIL FROM parsing test in unittest

9 years agosmtp-layer: add HELO parsing test in unittest
Eric Leblond [Tue, 12 May 2015 15:31:56 +0000 (17:31 +0200)] 
smtp-layer: add HELO parsing test in unittest

9 years agoyaml: add comment describing smtp extended
Eric Leblond [Tue, 12 May 2015 14:55:49 +0000 (16:55 +0200)] 
yaml: add comment describing smtp extended

9 years agoemail-json: add 'date' field extraction
Eric Leblond [Tue, 12 May 2015 14:53:20 +0000 (16:53 +0200)] 
email-json: add 'date' field extraction

9 years agoutil-decode-mime: add unittests for field fetching
Eric Leblond [Tue, 12 May 2015 14:52:12 +0000 (16:52 +0200)] 
util-decode-mime: add unittests for field fetching

9 years agounittests: finally register MIME tests
Eric Leblond [Tue, 12 May 2015 14:50:16 +0000 (16:50 +0200)] 
unittests: finally register MIME tests

9 years agoemail-json: improve log message
Eric Leblond [Thu, 7 May 2015 12:52:12 +0000 (14:52 +0200)] 
email-json: improve log message

9 years agoemail-json: add author
Eric Leblond [Thu, 7 May 2015 12:44:14 +0000 (14:44 +0200)] 
email-json: add author

Add myself as author and change the copyright date.

9 years agoyaml: document new MIME features
Eric Leblond [Tue, 5 May 2015 12:20:13 +0000 (14:20 +0200)] 
yaml: document new MIME features

9 years agoemail-json: add some fields
Eric Leblond [Thu, 7 May 2015 09:38:15 +0000 (11:38 +0200)] 
email-json: add some fields

This patch adds some fields to the list of extracted fields.

9 years agoemail-json: body md5 logging is optional
Eric Leblond [Tue, 5 May 2015 13:16:35 +0000 (15:16 +0200)] 
email-json: body md5 logging is optional

9 years agoemail-json: add capa to display subject md5
Eric Leblond [Tue, 5 May 2015 09:55:46 +0000 (11:55 +0200)] 
email-json: add capa to display subject md5

To be able to identify mails with identical subjects without
using the subject itself as a key, it is possible to use the md5
hash of the subjet string. This allows to limit the privacy impact.

9 years agoemail-json: don't log subject by default
Eric Leblond [Tue, 5 May 2015 08:32:16 +0000 (10:32 +0200)] 
email-json: don't log subject by default

It seems to be a bit too intrusive for the privacy so this patch
adds this field to the extended logging only.

9 years agodecode-mime: fix typo in comment
Eric Leblond [Tue, 5 May 2015 08:16:10 +0000 (10:16 +0200)] 
decode-mime: fix typo in comment

9 years agoemail-json: delete white space from "from"
Eric Leblond [Mon, 4 May 2015 16:14:03 +0000 (18:14 +0200)] 
email-json: delete white space from "from"

The From field is handled separatly and it could also starts by
white spaces.

9 years agoemail-json: delete leading white spaces
Eric Leblond [Mon, 4 May 2015 16:11:37 +0000 (18:11 +0200)] 
email-json: delete leading white spaces

Some mail clients are using tabulation and/or space for comma
separated list. This patch removes them so the event will contain
only significative characters.

9 years agoemail-json: factorize the code
Eric Leblond [Mon, 4 May 2015 15:42:33 +0000 (17:42 +0200)] 
email-json: factorize the code

9 years agoemail-json: add LOG_EMAIL_COMMA type
Eric Leblond [Mon, 4 May 2015 15:35:27 +0000 (17:35 +0200)] 
email-json: add LOG_EMAIL_COMMA type

extract these data types by treating them as a comma separated list.

9 years agoemail-json: add custom fields support
Eric Leblond [Tue, 5 May 2015 12:33:50 +0000 (14:33 +0200)] 
email-json: add custom fields support

This patch adds a way to specify which MIME fields to log via
the custom keyword in the EVE configuration. it also adds an
extended logging where some fields are added. The logging support
mono value fields as well as multivalue fields via the use of
JSON array.

9 years agodecode-mime: introduce MimeDecFindFieldsForEach
Eric Leblond [Tue, 5 May 2015 12:31:55 +0000 (14:31 +0200)] 
decode-mime: introduce MimeDecFindFieldsForEach

This patch introduces a new function that can be used to handle
multivalued MIME fields. A callback function can be called for
each corresponding field value.

9 years agofile-json: log 'email' information
Eric Leblond [Thu, 30 Apr 2015 13:24:52 +0000 (15:24 +0200)] 
file-json: log 'email' information

Log information coming from email/MIME decoding in the message.

9 years agoemail-json: add function to export data
Eric Leblond [Thu, 30 Apr 2015 12:45:52 +0000 (14:45 +0200)] 
email-json: add function to export data

9 years agofile-json: output smtp proto info
Eric Leblond [Thu, 30 Apr 2015 11:44:58 +0000 (13:44 +0200)] 
file-json: output smtp proto info

9 years agosmtp-json: introduce function to output smtp data
Eric Leblond [Thu, 30 Apr 2015 11:28:49 +0000 (13:28 +0200)] 
smtp-json: introduce function to output smtp data

9 years agofile-json: log http data using common function
Eric Leblond [Thu, 30 Apr 2015 10:53:09 +0000 (12:53 +0200)] 
file-json: log http data using common function

9 years agoalert-json: use new JsonHttpAddMetadata function
Eric Leblond [Thu, 30 Apr 2015 10:52:22 +0000 (12:52 +0200)] 
alert-json: use new JsonHttpAddMetadata function

This patch uses the newly introduced function to handle the logging
of HTTP data.

9 years agohttp-json: introduce JsonHttpAddMetadata function
Eric Leblond [Thu, 30 Apr 2015 09:08:47 +0000 (11:08 +0200)] 
http-json: introduce JsonHttpAddMetadata function

This function will be usable in other logging components to add
the http data to their messages.

9 years agoemail-json: output MIME parsing status
Eric Leblond [Wed, 29 Apr 2015 16:25:05 +0000 (18:25 +0200)] 
email-json: output MIME parsing status

If the status is not PARSE_DONE then in that case we may have
imcomplete information. Increasing the stream reassemly depth
in that case would be a good idea.

9 years agodecode-mime: add function to get status
Eric Leblond [Wed, 29 Apr 2015 16:24:09 +0000 (18:24 +0200)] 
decode-mime: add function to get status

This new function return the textual status of MIME parsing.

9 years agosmtp: add 'body-md5' mime option
Eric Leblond [Tue, 5 May 2015 13:00:58 +0000 (15:00 +0200)] 
smtp: add 'body-md5' mime option

This option will allow the user to select weither or not he wants
to journalize the md5 of the mail body.

9 years agoemail-json: export md5sum of body
Eric Leblond [Tue, 28 Apr 2015 11:23:23 +0000 (13:23 +0200)] 
email-json: export md5sum of body

The body_md5 has been added and contain the value of the md5sum
of the body.

This patch is using the state PARSE_DONE on the MIME state to
detect when a message has been completely parsed.

9 years agodecode-mime: compute body md5
Eric Leblond [Fri, 24 Apr 2015 14:17:19 +0000 (16:17 +0200)] 
decode-mime: compute body md5

This patch is computing the md5 sum of the body of the MIME message.
This will allow to detect messages with same content and sent to
different people.

9 years agoapp-layer-stmp: simplify code
Eric Leblond [Fri, 24 Apr 2015 11:25:41 +0000 (13:25 +0200)] 
app-layer-stmp: simplify code

Delete a only used once goto to a point where we only do a return.

9 years agooutput-json-smtp: output RCPT TO fields
Eric Leblond [Wed, 22 Apr 2015 12:41:20 +0000 (14:41 +0200)] 
output-json-smtp: output RCPT TO fields

This patch uses an array to output the RCPT TO fields to the
JSON message.

9 years agoapp-layer-smtp: parse and extract RCPT TO fields
Eric Leblond [Wed, 22 Apr 2015 12:40:30 +0000 (14:40 +0200)] 
app-layer-smtp: parse and extract RCPT TO fields

Add the RCPT TO fields to a linked list stored in the transaction.

9 years agosmtp-json: update SMTP EVE messages
Eric Leblond [Fri, 17 Apr 2015 14:34:56 +0000 (16:34 +0200)] 
smtp-json: update SMTP EVE messages

This patch updates SMTP message to have them feature a 'smtp'
section which will contain all fields coming from the smtp
protocol.

9 years agoapp-layer-smtp: extract and store HELO and MAIL FROM
Eric Leblond [Fri, 17 Apr 2015 08:46:15 +0000 (10:46 +0200)] 
app-layer-smtp: extract and store HELO and MAIL FROM

This patch updates the SMTP transaction and SMTP state to be able
to contain the HELO and MAIL FROM fields.

9 years agoemail-json: move email fields to email section
Eric Leblond [Fri, 17 Apr 2015 14:13:23 +0000 (16:13 +0200)] 
email-json: move email fields to email section

This patch changes the way smtp message are written. It is using
the "email" key to store the email related fields. This will
allow to do the same search through SMTP and IMAP if we implement
this last one.

9 years agothreshold: remove debug message from info loglevel
Victor Julien [Tue, 29 Sep 2015 20:07:57 +0000 (22:07 +0200)] 
threshold: remove debug message from info loglevel

9 years agoflow: add missing storage size to checks, output 1652/head
Victor Julien [Mon, 21 Sep 2015 06:34:19 +0000 (08:34 +0200)] 
flow: add missing storage size to checks, output

9 years agohost: update host size logic
Victor Julien [Sun, 20 Sep 2015 20:54:32 +0000 (22:54 +0200)] 
host: update host size logic

Instead of using (sizeof(Host)+HostStorageSize()) in many places,
create a simple size variable that is set during setup.

9 years agoippair: update ippair size logic
Victor Julien [Sun, 20 Sep 2015 20:39:17 +0000 (22:39 +0200)] 
ippair: update ippair size logic

Instead of using (sizeof(IPPair)+IPPairStorageSize()) in many places,
create a simple size variable that is set during setup.

9 years agostream: improve retransmission detection
Victor Julien [Mon, 21 Sep 2015 13:01:56 +0000 (15:01 +0200)] 
stream: improve retransmission detection

Consider packets starting before last_ack and ending after it also
to be retransmissions. This way we can see if they are having
different data.

9 years agompm: SGH maxlen was actually minlen, so rename
Victor Julien [Sat, 19 Sep 2015 19:56:29 +0000 (21:56 +0200)] 
mpm: SGH maxlen was actually minlen, so rename

9 years agompm: improve SGH content len tracking
Victor Julien [Sat, 19 Sep 2015 19:46:34 +0000 (21:46 +0200)] 
mpm: improve SGH content len tracking

SGH's track content length for rule grouping.

This patch changes the logic to only consider the pattern that is
used in the mpm for a sig.

9 years agompm: redo uri maxlen logic
Victor Julien [Sat, 19 Sep 2015 18:53:26 +0000 (20:53 +0200)] 
mpm: redo uri maxlen logic

The mpm_uricontent_maxlen logic was meant to track the shortest
possible pattern in the MPM of a SGH. So a minlen more than a maxlen.

This patch replaces the complicated tracking logic by a simpler
scheme. When the SGH's are finalize, the minlen is calculated.

It also fixes a small corner case where the calculated "maxlen" could
be wrong. This would require a smaller pattern in a rule to be forced
as fast pattern.

9 years agodetect: improve comments on mpm
Victor Julien [Sat, 19 Sep 2015 17:33:14 +0000 (19:33 +0200)] 
detect: improve comments on mpm

9 years agompm: remove used counter
Victor Julien [Sat, 19 Sep 2015 17:28:52 +0000 (19:28 +0200)] 
mpm: remove used counter

9 years agompm: remove bloated counting logic
Victor Julien [Sat, 19 Sep 2015 16:56:43 +0000 (18:56 +0200)] 
mpm: remove bloated counting logic

Counters were only used to print debug info.

9 years agompm: improve debug output
Victor Julien [Sat, 19 Sep 2015 16:41:51 +0000 (18:41 +0200)] 
mpm: improve debug output

9 years agompm: use IPPROTO_TCP for readability
Victor Julien [Sat, 19 Sep 2015 16:41:36 +0000 (18:41 +0200)] 
mpm: use IPPROTO_TCP for readability

9 years agompm: optimize & debug validate
Victor Julien [Sat, 19 Sep 2015 11:58:03 +0000 (13:58 +0200)] 
mpm: optimize & debug validate

Wrappers are called only if a mpm_ctx is available. So remove the test
for a null ctx and replace it by a debug validation BUG_ON.

9 years agompm: assume we'll likely have a mpm_ctx
Victor Julien [Sat, 19 Sep 2015 11:57:57 +0000 (13:57 +0200)] 
mpm: assume we'll likely have a mpm_ctx

9 years agompm: indent fix, no functional change
Victor Julien [Sat, 19 Sep 2015 11:24:47 +0000 (13:24 +0200)] 
mpm: indent fix, no functional change

9 years agompm: change direction checking in mpm wrappers
Victor Julien [Sat, 19 Sep 2015 11:13:55 +0000 (13:13 +0200)] 
mpm: change direction checking in mpm wrappers

Instead of having reachable assertions, use DEBUG_VALIDATE_BUG_ON

9 years agodebug validation: introduce DEBUG_VALIDATE_BUG_ON
Victor Julien [Sat, 19 Sep 2015 11:11:56 +0000 (13:11 +0200)] 
debug validation: introduce DEBUG_VALIDATE_BUG_ON

DEBUG_VALIDATE_BUG_ON(exp) will call BUG_ON(exp) if debug validation
is compiled in. Otherwise it's a no-op.

9 years agompm: minor fixes and cleanups
Victor Julien [Sat, 19 Sep 2015 11:11:35 +0000 (13:11 +0200)] 
mpm: minor fixes and cleanups

9 years agostream: improve handling of GAPs at stream start
Victor Julien [Mon, 31 Aug 2015 17:00:35 +0000 (19:00 +0200)] 
stream: improve handling of GAPs at stream start

Detect and handle gaps at the start of the stream, when there may
be no segments in the list (yet).

9 years agostream: RST last_ack update fix
Victor Julien [Thu, 27 Aug 2015 21:49:15 +0000 (23:49 +0200)] 
stream: RST last_ack update fix

Only use ACK if ACK flag was set and ACK value is valid.

9 years agoproto detect: more bypass conditions
Victor Julien [Thu, 27 Aug 2015 20:58:32 +0000 (22:58 +0200)] 
proto detect: more bypass conditions

More exceptional cases for protocol detection. In very unbalanced flows,
where just a few bytes are sent toserver and many toclient, proto detect
might not complete in time on the toserver direction. This can lead to
queuing up many segments in the toclient direction.

Another case is that in come cases the stream is flagged as proto detect
done, but the flows proto detect flags are not set. This is now handled
by the ProtoDetectDone() check.

9 years agodebug validation: add segment list sanity check
Victor Julien [Wed, 26 Aug 2015 14:52:09 +0000 (16:52 +0200)] 
debug validation: add segment list sanity check

9 years agodetect: fix issue with smsg and seq wraps
Victor Julien [Thu, 27 Aug 2015 16:57:48 +0000 (18:57 +0200)] 
detect: fix issue with smsg and seq wraps

Due to a broken sequence number check, detect could fail to process
smsgs in case of a sequence wrap. This could lead to excessive use
of smsg's but also of segments, since these aren't cleared until the
smsg containing them is.

9 years agostream: allow next_seq catch up after pkt loss
Victor Julien [Tue, 1 Sep 2015 20:46:14 +0000 (22:46 +0200)] 
stream: allow next_seq catch up after pkt loss

If next_seq falls behind last_ack, force update it.

9 years agostream: use reassembly fast path after proto detect
Victor Julien [Mon, 31 Aug 2015 16:50:06 +0000 (18:50 +0200)] 
stream: use reassembly fast path after proto detect

Use the reassembly fast paths only after protocol detection has completed.
In some corner cases the sending of smaller segments lead to protocol
detection failing.

9 years agostream: fix protocol detection issue for GAPs
Victor Julien [Wed, 26 Aug 2015 14:15:07 +0000 (16:15 +0200)] 
stream: fix protocol detection issue for GAPs

If the protocol required TOSERVER data first, but the SSN started with
a GAP, then the TOCLIENT side would get stuck in an expensive path:

1. it would run detection on TOCLIENT
2. it would try to force reassembly for TOSERVER
3. it would reset the detected protocol as TOSERVER failed
4. it would not evict any segment

This had 2 consequences:
1. on long running sessions this could lead to using lots of memory
   on segments, denying other sessions resources
2. wasted cycles on protocol detection and segment list management

This patch introduces a fix. It checks in the (2) stage above, whether
the opposing stream (that we depend on) it is a NOREASSEMBLY state. If
so, it gives up on this side of the session as well.