]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
11 years agodefrag: use 'struct timeval' for timeout tracking 1088/head
Victor Julien [Tue, 5 Aug 2014 15:28:17 +0000 (17:28 +0200)] 
defrag: use 'struct timeval' for timeout tracking

Until now the time out handling in defrag was done using a single
uint32_t that tracked seconds. This lead to corner cases, where
defrag trackers could be timed out a little too early.

11 years agoipv6: set event on unsupported nh
Victor Julien [Mon, 28 Jul 2014 12:41:15 +0000 (14:41 +0200)] 
ipv6: set event on unsupported nh

If a next header / protocol is encountered that we can't handle (yet)
set an event. Disabled the rule by default.

    decode-event:ipv6.unknown_next_header;

11 years agoipv6: more robust ipv6 exthdr handling
Victor Julien [Mon, 28 Jul 2014 11:59:44 +0000 (13:59 +0200)] 
ipv6: more robust ipv6 exthdr handling

Skip past Shim6, HIP and Mobility header.

Detect data after 'none' header.
    decode-event:ipv6.data_after_none_header;

11 years agoipv6: detect frag header reserved field non-zero
Victor Julien [Mon, 28 Jul 2014 10:07:13 +0000 (12:07 +0200)] 
ipv6: detect frag header reserved field non-zero

Frag Header length field is reserved, and should be set to 0.

    decode-event:ipv6.fh_non_zero_reserved_field;

11 years agoipv6: make exthdr parsing more robust
Victor Julien [Thu, 24 Jul 2014 14:50:34 +0000 (16:50 +0200)] 
ipv6: make exthdr parsing more robust

Improve data length checks. Detect PadN option with 0 length.

11 years agoipv6: set flag on type 0 routing header
Victor Julien [Thu, 17 Jul 2014 13:57:16 +0000 (15:57 +0200)] 
ipv6: set flag on type 0 routing header

Type 0 Routing headers are deprecated per RFC 5095.

This patch sets an decode event flag that can be matched on through:
    decode-event:ipv6.rh_type_0;

11 years agoipv6 defrag: fix unfragmentable exthdr handling
Victor Julien [Thu, 24 Jul 2014 11:39:10 +0000 (13:39 +0200)] 
ipv6 defrag: fix unfragmentable exthdr handling

Fix or rather implement handling of unfragmentable exthdrs in ipv6.
The exthdr(s) appearing before the frag header were copied into the
reassembled packet correctly, however the stripping of the frag header
did not work correctly.

Example:
The common case is a frag header directly after the ipv6 header:

[ipv6 header]->[frag header]->[icmpv6 (part1)]
[ipv6 header]->[frag header]->[icmpv6 (part2)]

This would result in:
[ipv6 header]->[icmpv6]

The ipv6 headers 'next header' setting would be updated to point to
whatever the frag header was pointing to.

This would also happen when is this case:

[ipv6 header]->[hop header]->[frag header]->[icmpv6 (part1)]
[ipv6 header]->[hop header]->[frag header]->[icmpv6 (part2)]

The result would be:
[ipv6 header]->[hop header]->[icmpv6]

However, here too the ipv6 header would have been updated to point
to what the frag header pointed at. So it would consider the hop header
as if it was an ICMPv6 header, or whatever the frag header pointed at.

The result is that packets would not be correctly parsed, and thus this
issue can lead to evasion.

This patch implements handling of the unfragmentable part. In the first
segment that is stored in the list for reassembly, this patch detects
unfragmentable headers and updates it to have the last unfragmentable
header point to the layer after the frag header.

Also, the ipv6 headers 'next hdr' is only updated if no unfragmentable
headers are used. If they are used, the original value is correct.

Reported-By: Rafael Schaefer <rschaefer@ernw.de>
Bug #1244.

11 years agopacket pool: init pthread key before using it 1083/head
Victor Julien [Fri, 1 Aug 2014 07:55:43 +0000 (09:55 +0200)] 
packet pool: init pthread key before using it

In the packet pool code, it's critical to initialize the pthread key
before using it. Applies only to the code used if __thread isn't
supported.

11 years agopacket pool: cosmetic cleanups
Victor Julien [Fri, 1 Aug 2014 07:54:34 +0000 (09:54 +0200)] 
packet pool: cosmetic cleanups

11 years agoprscript: update URL
Eric Leblond [Thu, 31 Jul 2014 09:48:41 +0000 (11:48 +0200)] 
prscript: update URL

Buildbot server has been moved to another box.

11 years agomagic: disable tests depending on magic version
Victor Julien [Thu, 31 Jul 2014 13:49:11 +0000 (15:49 +0200)] 
magic: disable tests depending on magic version

Some tests depend on specific results by specific magic versions.
Disable these.

11 years agosuricata: RunUnittests now return void
Eric Leblond [Wed, 30 Jul 2014 15:17:51 +0000 (17:17 +0200)] 
suricata: RunUnittests now return void

RunUnittests function is now a terminal function (calling exit
before leaving).

11 years agounittests: don't register app layer test
Eric Leblond [Tue, 29 Jul 2014 08:05:23 +0000 (10:05 +0200)] 
unittests: don't register app layer test

Some tests are already registered via the function
AppLayerParserRegisterProtocolUnittests. So we don't need to
egister them during runmode initialization.

11 years agoFix up mistaken style change
Victor Julien [Thu, 31 Jul 2014 10:17:58 +0000 (12:17 +0200)] 
Fix up mistaken style change

11 years agofixup 1076/head
Ken Steele [Wed, 30 Jul 2014 18:44:45 +0000 (14:44 -0400)] 
fixup

11 years agoEnforce function coding standard
Ken Steele [Wed, 30 Jul 2014 18:19:35 +0000 (14:19 -0400)] 
Enforce function coding standard

Functions should be defined as:

int foo(void)
{
}

Rather than:
int food(void) {
}

All functions where changed by a script to match this standard.

11 years agoeve: add tx_id to output for alerts and events 1071/head
Victor Julien [Sat, 12 Jul 2014 07:25:21 +0000 (09:25 +0200)] 
eve: add tx_id to output for alerts and events

Add tx_id field for correlating alerts and events per tx.

11 years agoUpdate app-layer-htp.c
sxhlinux [Thu, 24 Jul 2014 02:00:40 +0000 (10:00 +0800)] 
Update app-layer-htp.c

When keyword "boundary=" doesn't exist in the http_header, the value of r is 0 and this condition shouldn't return 0 instead 1;

11 years agoReduce reallocation in AC Tile MPM creation.
Ken Steele [Thu, 3 Jul 2014 16:42:12 +0000 (12:42 -0400)] 
Reduce reallocation in AC Tile MPM creation.

Exponentially increase the memory allocated for new states when adding new
states, then at the end resize down to the actually final size so that no space is wasted.

11 years agoAdd input interface's name to JSON log
Alexander Gozman [Mon, 28 Jul 2014 16:22:32 +0000 (20:22 +0400)] 
Add input interface's name to JSON log

11 years agopcap-log: yaml comment update 1070/head
Victor Julien [Wed, 30 Jul 2014 09:00:53 +0000 (11:00 +0200)] 
pcap-log: yaml comment update

11 years agopcap-log: unify lock handling, fixes Coverity warn
Victor Julien [Wed, 30 Jul 2014 08:58:30 +0000 (10:58 +0200)] 
pcap-log: unify lock handling, fixes Coverity warn

*** CID 1229124:  Data race condition  (MISSING_LOCK)
/src/log-pcap.c: 363 in PcapLog()
357         {
358             return TM_ECODE_OK;
359         }
360
361         PcapLogLock(pl);
362
>>>     CID 1229124:  Data race condition  (MISSING_LOCK)
>>>     Accessing "pl->pkt_cnt" without holding lock "PcapLogData_.plog_lock". Elsewhere, "PcapLogData_.pkt_cnt" is accessed with "PcapLogData_.plog_lock" held 1 out of 2 times (1 of these accesses strongly imply that it is necessary).
363         pl->pkt_cnt++;
364         pl->h->ts.tv_sec = p->ts.tv_sec;
365         pl->h->ts.tv_usec = p->ts.tv_usec;
366         pl->h->caplen = GET_PKT_LEN(p);
367         pl->h->len = GET_PKT_LEN(p);
368         len = sizeof(*pl->h) + GET_PKT_LEN(p);

11 years agoCleanup Packet Pools when done.
Ken Steele [Tue, 29 Jul 2014 15:13:56 +0000 (11:13 -0400)] 
Cleanup Packet Pools when done.

11 years agoFix Packet Stacks for non-TLS Operating Systems
Ken Steele [Tue, 29 Jul 2014 13:31:49 +0000 (09:31 -0400)] 
Fix Packet Stacks for non-TLS Operating Systems

On non-TLS systems, check each time the Thread Local Storage
is requested and if it has not been initialized for this thread, initialize it.
The prevents not initializing the worker threads in autofp run mode.

11 years agotravis-ci: use make check
Eric Leblond [Fri, 4 Jul 2014 15:00:55 +0000 (17:00 +0200)] 
travis-ci: use make check

This patch replaces unittest run by make check. It also install
coccinelle so we should have more test.

11 years agococcinelle: fix problem with coccinelle 1.0rc21
Eric Leblond [Tue, 1 Jul 2014 17:27:34 +0000 (19:27 +0200)] 
coccinelle: fix problem with coccinelle 1.0rc21

coccinelle 1.0rc21 has a problem with regular expression handling.
This result in a Fatal Error when test system detects an coding
error.

This patch fixes the problem by using a simple blob inside
semantic patch instead of using a regular expression to define
the function.

It also fixes add an optimization on matching suppressing a
useless <.. ..> construction.

Fixes have been suggested by Julia Lawall.

11 years agoflow-recycler: support multiple instances 1058/head
Victor Julien [Mon, 21 Jul 2014 13:13:42 +0000 (15:13 +0200)] 
flow-recycler: support multiple instances

Use new management API to run the flow recycler.

Make number of threads configurable:

flow:
  memcap: 64mb
  hash-size: 65536
  prealloc: 10000
  emergency-recovery: 30
  managers: 2
  recyclers: 2

This sets up 2 flow recyclers.

11 years agoflow-manager: support multiple instances
Victor Julien [Sat, 12 Jul 2014 11:47:33 +0000 (13:47 +0200)] 
flow-manager: support multiple instances

Use new management API to run the flow manager.

Support multiple flow managers, where each of them works with it's
own part of the flow hash.

Make number of threads configurable:

flow:
  memcap: 64mb
  hash-size: 65536
  prealloc: 10000
  emergency-recovery: 30
  managers: 2

This sets up 2 flow managers.

Handle misc tasks only in instance 1: Handle defrag hash timeout
handing, host hash timeout handling and flow spare queue updating
only from the first instance.

11 years agothreads: add management API
Victor Julien [Wed, 16 Jul 2014 07:59:48 +0000 (09:59 +0200)] 
threads: add management API

Currently management threads do their own thread setup and handling. This
patch introduces a new way of handling management threads.

Functionality that needs to run as a management thread can now register
itself as a regular 'thread module' (TmModule), where the 'Management'
callback is registered.

11 years agoflow id: quick and dirty first stab at a flow id
Victor Julien [Wed, 4 Jun 2014 11:37:02 +0000 (13:37 +0200)] 
flow id: quick and dirty first stab at a flow id

Add a 'flow_id' that is the same for all records produced for packets
belonging to the same flow.

This patch simply takes the flow's memory address.

11 years agoflow: add flow_end_flags field, add logging
Victor Julien [Fri, 23 May 2014 12:54:05 +0000 (14:54 +0200)] 
flow: add flow_end_flags field, add logging

The flow end flags field is filled by the flow manager or the flow
hash (in case of forced timeout of a flow) to record the timeout
conditions in the flow:
- emergency mode
- state
- reason (timed out or forced)

Add logging to the flow logger.

11 years agoflow: move FlowGetFlowState
Victor Julien [Fri, 23 May 2014 12:51:44 +0000 (14:51 +0200)] 
flow: move FlowGetFlowState

Move FlowGetFlowState to flow-private.h so that all parts of the flow
engine can use it.

11 years agoflow log: log TCP state
Victor Julien [Fri, 23 May 2014 09:49:37 +0000 (11:49 +0200)] 
flow log: log TCP state

Log the TCP state at timeout.

11 years agoflow-recycler: speed up flow-recycler shutdown
Victor Julien [Thu, 22 May 2014 10:53:51 +0000 (12:53 +0200)] 
flow-recycler: speed up flow-recycler shutdown

Thread was killed by the generic TmThreadKillThreads instead of
the FlowKillFlowRecyclerThread. The latter wakes the thread up, so
that shutdown is quite a bit faster.

11 years agoflow: log individual tcp flags
Victor Julien [Thu, 22 May 2014 10:39:12 +0000 (12:39 +0200)] 
flow: log individual tcp flags

Log the tcp flags.

11 years agonetflow: log individual tcp flags
Victor Julien [Thu, 22 May 2014 10:37:27 +0000 (12:37 +0200)] 
netflow: log individual tcp flags

Log the tcp flags.

11 years agojson: add tcp flags to json utility function
Victor Julien [Thu, 22 May 2014 10:36:45 +0000 (12:36 +0200)] 
json: add tcp flags to json utility function

Turns a flags bitfield into a set of json bools.

11 years agonetflow-json: initial version
Victor Julien [Wed, 21 May 2014 14:54:18 +0000 (16:54 +0200)] 
netflow-json: initial version

Initial version of netflow module, a flow logger that logs each
direction in a completely separate record (line).

11 years agoflow-log: log TCP flags per direction
Victor Julien [Wed, 21 May 2014 13:37:10 +0000 (15:37 +0200)] 
flow-log: log TCP flags per direction

In addition to flags for the entire session, also log out TCP flags
for both directions separately.

11 years agostream: track TCP flags per stream direction
Victor Julien [Wed, 21 May 2014 12:29:15 +0000 (14:29 +0200)] 
stream: track TCP flags per stream direction

For netflow logging track TCP flags per stream direction. As the struct
had no more space left without expanding it, the flags and wscale
fields are now compressed.

11 years agoflow: init logger thread data for decoders
Victor Julien [Fri, 9 May 2014 12:56:55 +0000 (14:56 +0200)] 
flow: init logger thread data for decoders

Initialize the output flow api thread data for the decoder threads.

11 years agodecode: pass ThreadVars to DecodeThreadVarsFree
Victor Julien [Fri, 9 May 2014 13:10:54 +0000 (15:10 +0200)] 
decode: pass ThreadVars to DecodeThreadVarsFree

Flow output thread data deinit function which will be called from
DecodeThreadVarsFree will need it.

11 years agoflow: prepare flow forced reuse logging
Victor Julien [Fri, 9 May 2014 12:37:07 +0000 (14:37 +0200)] 
flow: prepare flow forced reuse logging

Most flows are marked for clean up by the flow manager, which then
passes them to the recycler. The recycler logs and cleans up. However,
under resource stress conditions, the packet threads can recycle
existing flow directly. So here the recycler has no role to play, as
the flow is immediately used.

For this reason, the packet threads need to be able to invoke the
flow logger directly.

The flow logging thread ctx will stored in the DecodeThreadVars
stucture. Therefore, this patch makes the DecodeThreadVars an argument
to FlowHandlePacket.

11 years agoflow: take flow pkt & byte count out of debug
Victor Julien [Wed, 7 May 2014 07:16:46 +0000 (09:16 +0200)] 
flow: take flow pkt & byte count out of debug

Until now the flow packet and byte counters were only available in
DEBUG mode. For logging purposes they are now available always.

11 years agoflow: don't BUG_ON if no loggers are enabled
Victor Julien [Tue, 6 May 2014 18:48:47 +0000 (20:48 +0200)] 
flow: don't BUG_ON if no loggers are enabled

API is always called, even if no loggers are enabled. Don't abort()
in this case.

11 years agoflow: clean up recycle queue at shutdown
Victor Julien [Tue, 6 May 2014 18:37:41 +0000 (20:37 +0200)] 
flow: clean up recycle queue at shutdown

Mostly for tests that don't start the recycler thread, make sure
all flows are cleaned up.

11 years agoflow unittest: update flow manager unit test
Victor Julien [Tue, 6 May 2014 11:47:18 +0000 (13:47 +0200)] 
flow unittest: update flow manager unit test

Test now tests a different queue.

11 years agoflow: track lastts in struct timeval
Victor Julien [Tue, 6 May 2014 10:15:39 +0000 (12:15 +0200)] 
flow: track lastts in struct timeval

Track full timestamp for lastts in flows to be able to log it.

11 years agoflow: track bytes per direction
Victor Julien [Tue, 6 May 2014 09:54:28 +0000 (11:54 +0200)] 
flow: track bytes per direction

Track bytes in both flow directions for logging purposes.

11 years agoflow log: log start/end times
Victor Julien [Tue, 6 May 2014 08:11:49 +0000 (10:11 +0200)] 
flow log: log start/end times

Log time of first packet (flow creation) and of the last packet.

11 years agoflow-log: log TCP flags seen
Victor Julien [Fri, 2 May 2014 07:54:16 +0000 (09:54 +0200)] 
flow-log: log TCP flags seen

Log TCP flags seen during the life time of a flow/session.

11 years agotcp: track TCP packet flags per session
Victor Julien [Fri, 2 May 2014 07:45:01 +0000 (09:45 +0200)] 
tcp: track TCP packet flags per session

For logging out in flow logging.

11 years agoflow-log: log pkts, bytes
Victor Julien [Fri, 2 May 2014 06:25:22 +0000 (08:25 +0200)] 
flow-log: log pkts, bytes

Only in DEBUG currently.

11 years agoflow-json-log: stub
Victor Julien [Thu, 1 May 2014 15:31:31 +0000 (17:31 +0200)] 
flow-json-log: stub

Stub for JSON flow logger.

11 years agoflow: flow log threading setup
Victor Julien [Thu, 1 May 2014 15:30:32 +0000 (17:30 +0200)] 
flow: flow log threading setup

Set up threading for the flow logger.

11 years agoflow log: call logger from recycler
Victor Julien [Thu, 1 May 2014 12:18:59 +0000 (14:18 +0200)] 
flow log: call logger from recycler

Call the flow logger API from the recycler thread, so that timed
out flows are logged.

11 years agoflow: output api stub
Victor Julien [Thu, 1 May 2014 11:31:10 +0000 (13:31 +0200)] 
flow: output api stub

Basic output API for flow logging.

11 years agoflow recycler: unix socket support
Victor Julien [Thu, 1 May 2014 10:50:02 +0000 (12:50 +0200)] 
flow recycler: unix socket support

Support starting and shutting down the flow recycler thread in the
unix socket runmode.

11 years agoflow recycler: shutdown
Victor Julien [Wed, 30 Apr 2014 16:49:39 +0000 (18:49 +0200)] 
flow recycler: shutdown

Only shut down when all flows in the recycle queue have been processed.

11 years agoflow: move flow cleanup to new 'recycler'
Victor Julien [Wed, 30 Apr 2014 11:57:17 +0000 (13:57 +0200)] 
flow: move flow cleanup to new 'recycler'

Move Flow clean up from the flow manager to the new flow recycler.

11 years agoflow: introduce FlowRecycler stub
Victor Julien [Wed, 30 Apr 2014 11:37:30 +0000 (13:37 +0200)] 
flow: introduce FlowRecycler stub

FlowRecycler thread stub. Start/stop code.

11 years agoflow: new flow queue: flow_recycle_q
Victor Julien [Wed, 30 Apr 2014 10:30:30 +0000 (12:30 +0200)] 
flow: new flow queue: flow_recycle_q

This queue will be used by the FlowManager to pass timed out flows
to another thread that will do the actual cleanup.

11 years agoFix eve 'filetype' parsing
Victor Julien [Mon, 28 Jul 2014 07:27:17 +0000 (09:27 +0200)] 
Fix eve 'filetype' parsing

Now that we use 'filetype' instead of 'type', we should also
use 'regular' instead of 'file'.

Added fallback to make sure we stay compatible to old configs.

11 years agoFixed memory leak
Alexander Gozman [Fri, 18 Jul 2014 20:02:19 +0000 (00:02 +0400)] 
Fixed memory leak

11 years agoFix possible crash when logfile descriptor is invalid
Alexander Gozman [Fri, 18 Jul 2014 16:36:12 +0000 (20:36 +0400)] 
Fix possible crash when logfile descriptor is invalid

11 years agoFix handling filetype for eve log
Alexander Gozman [Fri, 18 Jul 2014 16:34:23 +0000 (20:34 +0400)] 
Fix handling filetype for eve log

11 years agoFixed variables names in suricata.yaml.in Changed logging logic - now it's possible...
Alexander Gozman [Fri, 18 Jul 2014 09:38:03 +0000 (13:38 +0400)] 
Fixed variables names in suricata.yaml.in Changed logging logic - now it's possible to enable different payload dumping modes separately Fixed bug in dumping packet without stream segments Fixed indents

11 years agoChanged attribute name for printable payload
Alexander Gozman [Fri, 4 Jul 2014 14:19:33 +0000 (18:19 +0400)] 
Changed attribute name for printable payload

11 years agoChanged variable name when dumping single packet
Alexander Gozman [Tue, 17 Jun 2014 12:18:23 +0000 (16:18 +0400)] 
Changed variable name when dumping single packet

11 years agoAdd ability to encode payload in Base64
Alexander Gozman [Tue, 17 Jun 2014 11:41:14 +0000 (15:41 +0400)] 
Add ability to encode payload in Base64

11 years agoFixed stream handling Fixed some coding style issues
Alexander Gozman [Mon, 16 Jun 2014 16:53:20 +0000 (20:53 +0400)] 
Fixed stream handling Fixed some coding style issues

11 years agoAdd packet and payload logging to JSON alert output
Matt Carothers [Thu, 3 Apr 2014 17:58:57 +0000 (13:58 -0400)] 
Add packet and payload logging to JSON alert output

11 years agoFix engine getting stuck because of optimizations 1057/head
Victor Julien [Fri, 25 Jul 2014 15:41:34 +0000 (17:41 +0200)] 
Fix engine getting stuck because of optimizations

At -O1+ in both Gcc and Clang, PacketPoolWait would optimize the
wait loop in the wrong way. Adding a compiler barrier to prevent
this optimization issue.

11 years agoRemove unused variables 1055/head
Victor Julien [Fri, 25 Jul 2014 11:45:00 +0000 (13:45 +0200)] 
Remove unused variables

11 years agoFix packet pool pending stack adds
Victor Julien [Fri, 25 Jul 2014 11:50:38 +0000 (13:50 +0200)] 
Fix packet pool pending stack adds

Add packets after the first as the list/stack head as well.

11 years agoFix pcap packet acquisition methods
Victor Julien [Fri, 25 Jul 2014 11:47:59 +0000 (13:47 +0200)] 
Fix pcap packet acquisition methods

Fix pcap packet acquisition methods passing 0 to pcap_dispatch.
Previously they passed the packet pool size, but the packet_q_len
variable was now hardcoded at 0.

This patch sets packet_q_len to 64. If packet pool is empty, we fall
back to direct alloc. As the pcap_dispatch function is only called
when packet pool is not empty, we alloc at most 63 packets.

11 years agoUpdate max-pending-packet comments to show it is now per-thread. 1022/head 1053/head
Ken Steele [Wed, 9 Jul 2014 14:53:34 +0000 (10:53 -0400)] 
Update max-pending-packet comments to show it is now per-thread.

Updated suricata.yaml and comments in the code.

11 years agoAdd error checking for pthread_setspecific() and pthread_key_create().
Ken Steele [Wed, 2 Jul 2014 14:42:05 +0000 (10:42 -0400)] 
Add error checking for pthread_setspecific() and pthread_key_create().

11 years agoUse posix_memalign instead of mm_malloc on non-Windows systems.
Ken Steele [Wed, 2 Jul 2014 13:57:31 +0000 (09:57 -0400)] 
Use posix_memalign instead of mm_malloc on non-Windows systems.

11 years agoImplement thread specific data option when __thread is not available.
Ken Steele [Tue, 1 Jul 2014 21:10:00 +0000 (17:10 -0400)] 
Implement thread specific data option when __thread is not available.

11 years agoFor PktPool add local pending freed packets list.
Ken Steele [Mon, 30 Jun 2014 19:12:38 +0000 (15:12 -0400)] 
For PktPool add local pending freed packets list.

Better handle the autofp case where one thread allocates the majority
of the packets and other threads free those packets.

Add a list of locally pending packets. The first packet freed goes on the
pending list, then subsequent freed packets for the same Packet Pool are
added to this list until it hits a fixed number of packets, then the
entire list of packets is pushed onto the pool's return stack. If a freed
packet is not for the pending pool, it is freed immediately to its pool's
return stack, as before.

For the autofp case, since there is only one Packet Pool doing all the
allocation, every other thread will keep a list of pending packets for
that pool.

For the worker run mode, most packets are allocated and freed locally. For
the case where packets are being returned to a remote pool, a pending list
will be kept for one of those other threads, all others are returned as before.

Which remote pool for which to keep a pending list is changed each time the
pending list is returned. Since the return pending pool is cleared when it is
freed, then next packet to be freed chooses the new pending pool.

11 years agoReplace ringbuffer in Packet Pool with a stack for better cache locality
Ken Steele [Fri, 28 Mar 2014 18:51:25 +0000 (14:51 -0400)] 
Replace ringbuffer in Packet Pool with a stack for better cache locality

Using a stack for free Packet storage causes recently freed Packets to be
reused quickly, while there is more likelihood of the data still being in
cache.

The new structure has a per-thread private stack for allocating Packets
which does not need any locking. Since Packets can be freed by any thread,
there is a second stack (return stack) for freeing packets by other threads.
The return stack is protected by a mutex. Packets are moved from the return
stack to the private stack when the private stack is empty.

Returning packets back to their "home" stack keeps the stacks from getting out
of balance.

The PacketPoolInit() function is now called by each thread that will be
allocating packets. Each thread allocates max_pending_packets, which is a
change from before, where that was the total number of packets across all
threads.

11 years agoAC: shrink output table after initialization 1049/head
Victor Julien [Thu, 10 Jul 2014 08:51:32 +0000 (10:51 +0200)] 
AC: shrink output table after initialization

11 years agoAC: reduce realloc for new states
Victor Julien [Fri, 4 Jul 2014 07:02:20 +0000 (09:02 +0200)] 
AC: reduce realloc for new states

Don't realloc per state add, but grow by larger blocks per realloc.

11 years agoFix Boyer Moore Nocase bug where BoyerMooreCtxToNocase was missing. 1047/head
Ken Steele [Fri, 18 Jul 2014 16:14:06 +0000 (12:14 -0400)] 
Fix Boyer Moore Nocase bug where BoyerMooreCtxToNocase was missing.

Whenever DETECT_CONTENT_NOCASE is set for a BoyerMoore matcher, the
function BoyerMooreCtxToNocase() must be called. This call was missing
in AppLayerProtoDetectPMRegisterPattern().

Also created BoyerMooreNocaseCtxInit() that calls BoyerMooreCtxToNocase()
to make some code cleaner and safer.

11 years agoStore Boyer Moore no case strings in lower case.
Ken Steele [Fri, 11 Jul 2014 15:17:13 +0000 (11:17 -0400)] 
Store Boyer Moore no case strings in lower case.

Rather than converting the search string to lower case while searching,
convert it to lowercase during initialization.

Changes the Boyer Moore search API for take BmCtx

Change the API for BoyerMoore to take a BmCtx rather than the two parts that
are stored in the context. Which is how it is mostly used. This enforces
always calling BoyerMooreCtxToNocase() to convert to no-case.

Use CtxInit and CtxDeinit functions to create and destroy the context,
even in unit tests.

11 years agoFix comment wording in Boyer Moore pattern matcher.
Ken Steele [Tue, 24 Jun 2014 14:05:03 +0000 (10:05 -0400)] 
Fix comment wording in Boyer Moore pattern matcher.

11 years agoRemove pcapinfo output
Eric Leblond [Sat, 14 Jun 2014 10:16:17 +0000 (12:16 +0200)] 
Remove pcapinfo output

EVE logging is a really good substitute for pcapinfo. Suriwire is
now supporting EVE output so it is not anymore necessary to have
pcapinfo in Suricata.

11 years agopcap log: document multi option 1045/head
Victor Julien [Tue, 10 Jun 2014 09:22:15 +0000 (11:22 +0200)] 
pcap log: document multi option

Add yaml documentation for new 'multi' option.

11 years agopcap-log: support dynamic file names in multi
Victor Julien [Fri, 6 Jun 2014 14:05:11 +0000 (16:05 +0200)] 
pcap-log: support dynamic file names in multi

When using multi mode, the filename can use a few variables:

%n -- thread number, where the 1st thread has 1, and it increments
%i -- thread id (system thread id, similar to pid)
%t -- timestamp, where seconds or seconds+usecs depends on
      the ts-format option.

Example:
filename: filename: pcaps/%n/pcap.%t
This will translate to: pcaps/3/pcap.1256792217 for the 3rd thread.

Note that while it's possible to use directories, they won't be
created. So make sure they exist.

11 years agopcap-log: performance optimizations
Victor Julien [Tue, 25 Feb 2014 16:04:24 +0000 (17:04 +0100)] 
pcap-log: performance optimizations

This patch adds a field 'is_private' to PcapLogData, so that the
using thread knows if it needs to lock access to it or not.

Reshuffle PcapLogData to roughly match order of access.

11 years agopcap-log: implement multi mode
Victor Julien [Tue, 25 Feb 2014 13:43:33 +0000 (14:43 +0100)] 
pcap-log: implement multi mode

This patch implements a new mode in pcap-logging: 'multi'. It stores
a pcap file per logger thread, instead of just one file globally.

This removes lock contention, so it brings a lot more performance.

The trade off is that there are now mulitple files where there would
be one before.

Files have a thread id added to their name: base_name.tid.ts, so by
we have something like: "log.pcap.20057.1254500095".

11 years agopcap-log: introduce PcapLogThreadData
Victor Julien [Tue, 25 Feb 2014 10:59:05 +0000 (11:59 +0100)] 
pcap-log: introduce PcapLogThreadData

PcapLog uses the global data structure PcapLogData as thread data
as well. This is possible because all operations on it are locked.

This patch introduces PcapLogThreadData. It contains a pointer to
the PcapLogData. Currently to the global instance, but in the future
it may hold a thread-local instance of PcapLogData.

11 years agolog-pcap: multi mode yaml parsing
Victor Julien [Tue, 25 Feb 2014 10:45:10 +0000 (11:45 +0100)] 
log-pcap: multi mode yaml parsing

In preparation of the multi file mode, add 'multi' as a value to
the mode.

11 years agolog-pcap: lock profiling
Victor Julien [Tue, 25 Feb 2014 09:43:23 +0000 (10:43 +0100)] 
log-pcap: lock profiling

Add lock profiling to pcap logging profiling.

11 years agolog-pcap: improve profiling
Victor Julien [Wed, 8 Jan 2014 11:40:30 +0000 (12:40 +0100)] 
log-pcap: improve profiling

Add profiling to a logfile. Default is $log_dir/pcaplog_stats.log

The counters for open, close, rotate, write and handles are written
to it, as well as:
- total bytes written
- cost per MiB
- cost per GiB

Option is disabled by default.

11 years agoUpdate log-pcap.h, add license
Victor Julien [Tue, 7 Jan 2014 12:56:09 +0000 (13:56 +0100)] 
Update log-pcap.h, add license

Clean up log-pcap.h and add the OISF license header.

11 years agolog-pcap code cleanups
Victor Julien [Tue, 7 Jan 2014 12:54:12 +0000 (13:54 +0100)] 
log-pcap code cleanups

Code cleanups to make functions static.

11 years agoprofiling: add pcap logger profiling
Victor Julien [Mon, 6 Jan 2014 17:20:28 +0000 (18:20 +0100)] 
profiling: add pcap logger profiling

Tracks: file open, file close, file rotate (which includes open and
close), file write and open handles.

Open handles measures the cost of open the libpcap handles.

11 years agoUpdate version number to 2.1dev
Victor Julien [Wed, 16 Jul 2014 10:35:42 +0000 (12:35 +0200)] 
Update version number to 2.1dev