]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
11 years agostream: configurable stream chunk prealloc 801/head
Victor Julien [Tue, 28 Jan 2014 16:13:05 +0000 (17:13 +0100)] 
stream: configurable stream chunk prealloc

The stream chunk pool contains preallocating stream chunks (StreamMsg).
These are used for raw reassembly, used in raw content inspection by
the detection engine. The default setting so far has been 250, which
was hardcoded. This meant that in setups that needed more, allocs and
frees would be happen constantly.

This patch introduces a yaml option to set the 'prealloc' value in the
pool. The default is still 250.

stream.reassembly.chunk-prealloc

Related to feature #1093.

11 years agostream: silence stream.reassembly.raw message
Victor Julien [Tue, 28 Jan 2014 16:12:38 +0000 (17:12 +0100)] 
stream: silence stream.reassembly.raw message

11 years agostream: configurable segment pools
Victor Julien [Tue, 28 Jan 2014 12:48:26 +0000 (13:48 +0100)] 
stream: configurable segment pools

The stream reassembly engine uses a set of pools in which preallocated
segments are stored. There are various pools each with different packet
sizes. The goal is to lower memory presure. Until now, these pools were
hardcoded.

This patch introduces the ability to configure them fully from the yaml.
There can be at max 256 of these pools.

Yaml layout is as follows:

stream:
  reassemble:
    segments:
      - size: 2048
        prealloc: 3000
      - size: 4
        prealloc: 1000
      - size: 1024
        prealloc: 2000

The size is the packet size. The prealloc value indicates how many
segments are set up at startup.

The pools have no limit wrt how many segments can be used of a certain
size. If the engine needs more than the prealloc size, segments are
malloc'd and free'd. The only limit here is the stream.reassemble.memcap.

If the yaml part if omitted, the default values are the same as before.

Feature #1093

11 years agolog-filestore: convert to FiledataLog API 797/head
Victor Julien [Thu, 16 Jan 2014 14:23:03 +0000 (15:23 +0100)] 
log-filestore: convert to FiledataLog API

This patch converts the log-filestore module to use the new
FiledataLog API.

11 years agoIntroduce Filedata Logger API
Victor Julien [Thu, 16 Jan 2014 14:20:09 +0000 (15:20 +0100)] 
Introduce Filedata Logger API

A new logger API for registering file storage handlers. Where the
FileLog handler is called once per file, this handler will be called
for each data chunk so that storing the entire file is possible.

The logger call in the API is as follows:
    typedef int (*FiledataLogger)(ThreadVars *, void *thread_data,
        const Packet *, const File *, const FileData *, uint8_t flags);

All data is const, thus should be read only. The final flags field
is used to indicate to the caller that the file is new, or if it's
being closed.

Files use an internal unique id 'file_id' which can be used by the
loggers to create unique file names. This id can use the 'waldo'
feature of the log-filestore module. This patch moves that waldo
loading and storing logic to this API's implementation. A new
configuration directive 'file-store-waldo: <filename>' is added,
but the existing waldo settings will also continue to work.

11 years agolog-filestore: cleanups
Victor Julien [Wed, 15 Jan 2014 15:24:25 +0000 (16:24 +0100)] 
log-filestore: cleanups

Remove unused code.
Make functions static.
Move registration to the bottom.

11 years agolog-filestore: tag truncated files as such
Victor Julien [Wed, 15 Jan 2014 15:17:15 +0000 (16:17 +0100)] 
log-filestore: tag truncated files as such

Tag truncated files as truncated in the same way log-file does.

11 years agotx-logger: speed up
Victor Julien [Wed, 15 Jan 2014 13:25:32 +0000 (14:25 +0100)] 
tx-logger: speed up

By bailing out early in case no logger is enabled for the protocol,
a significant speed up is reached.

11 years agoapp-layer: add logger check to API
Victor Julien [Wed, 15 Jan 2014 13:23:16 +0000 (14:23 +0100)] 
app-layer: add logger check to API

The new API call:
    int AppLayerParserProtocolHasLogger(uint8_t ipproto,
                                        AppProto alproto)

Returns TRUE if a logger is registered on the ip/alproto pair, and
FALSE otherwise.

11 years agoprofiling: add logger api labels
Victor Julien [Wed, 15 Jan 2014 13:14:01 +0000 (14:14 +0100)] 
profiling: add logger api labels

11 years agolog-file: convert to file-logger API
Victor Julien [Wed, 15 Jan 2014 12:28:43 +0000 (13:28 +0100)] 
log-file: convert to file-logger API

Use file logger API.

Also, check if the protocol is HTTP before getting the HTTP
fields.

11 years agoIntroduce 'file' logging API
Victor Julien [Wed, 15 Jan 2014 12:22:47 +0000 (13:22 +0100)] 
Introduce 'file' logging API

This patch introduces a new logging API for logging extracted file info.
It allows for registration of a callback that is called once per file:
when it's considered 'closed'.

Users of this API register their Log Function through:
    OutputRegisterFileModule()

The API uses a magic settings globally. This might be changed later.

11 years agolog-file: cleanups
Victor Julien [Wed, 15 Jan 2014 09:59:15 +0000 (10:59 +0100)] 
log-file: cleanups

Make all functions static.
Move registration to the bottom.

11 years agoprelude: convert to packet logger API
Victor Julien [Tue, 14 Jan 2014 16:14:27 +0000 (17:14 +0100)] 
prelude: convert to packet logger API

Convert prelude logger to use the packet logger API.

11 years agoprelude: fix configure and cleanup
Victor Julien [Tue, 14 Jan 2014 16:02:33 +0000 (17:02 +0100)] 
prelude: fix configure and cleanup

Fixes configure enabling of prelude. CFLAGS is reset, so the previous
adding of -DPRELUDE was nixed. Using AC_DEFINE now.

Cleanups:
- make functions static
- simplify handling of no prelude support
- move registration to the bottom

11 years agoalert-syslog: convert to packet logger API
Victor Julien [Tue, 14 Jan 2014 15:39:41 +0000 (16:39 +0100)] 
alert-syslog: convert to packet logger API

Convert Syslog alert logger to packet logger API.

11 years agoalert-syslog: cleanup
Victor Julien [Tue, 14 Jan 2014 15:30:06 +0000 (16:30 +0100)] 
alert-syslog: cleanup

Remove separate ipv4 and ipv6 registration functions.
Make all functions static.
Move registration function to the bottom.
Simplify OS_WIN32 wrappers usage.

11 years agoalert-pcapinfo: convert to packet logger API
Victor Julien [Tue, 14 Jan 2014 15:20:27 +0000 (16:20 +0100)] 
alert-pcapinfo: convert to packet logger API

Convert pcap-info to use the packet logger API.

11 years agoalert-pcapinfo: clean up
Victor Julien [Tue, 14 Jan 2014 15:08:47 +0000 (16:08 +0100)] 
alert-pcapinfo: clean up

Make functions static.
Move registration to the bottom.

11 years agoalert-debuglog: minor cleanups
Victor Julien [Tue, 14 Jan 2014 09:47:18 +0000 (10:47 +0100)] 
alert-debuglog: minor cleanups

Clean up log functions after packet logger conversion. No more
PacketQueue arguments.

11 years agoalert-debuglog: port to packet logger api
Victor Julien [Tue, 14 Jan 2014 09:43:07 +0000 (10:43 +0100)] 
alert-debuglog: port to packet logger api

Convert AlertDebugLog to Packet logger API. Convert packet args to
const.

11 years agoalert-debug log cleanups
Victor Julien [Tue, 14 Jan 2014 09:07:27 +0000 (10:07 +0100)] 
alert-debug log cleanups

Make all funcs but registration static.
Remove stale registation prototypes.
Move registation func to the bottom.

11 years agolog-tls: convert to packet logger API
Victor Julien [Mon, 13 Jan 2014 15:13:27 +0000 (16:13 +0100)] 
log-tls: convert to packet logger API

This patch converts log-tls to use the packet logger API. The packet
logger API was choosen as the TLS parser is not transaction aware.

To make sure the state is only logged once, the flag
SSL_AL_FLAG_STATE_LOGGED was added to the parser. This flag is checked
by the condition function, and set at the end of the Logger function.

11 years agolog-tls: clean ups
Victor Julien [Mon, 13 Jan 2014 14:18:42 +0000 (15:18 +0100)] 
log-tls: clean ups

Make all functions static. Remove separate ipv4 and ipv6 registration
functions. Move register function to the bottom so that we no longer
need function prototype declarations.

11 years agodns: convert dns logger to TX logger API
Victor Julien [Sat, 7 Dec 2013 10:43:08 +0000 (11:43 +0100)] 
dns: convert dns logger to TX logger API

Make sure to use the new logger TX API. For this the transaction
handling was improved as well.

11 years agoConvert log-drop to packet logger api.
Victor Julien [Fri, 6 Dec 2013 11:33:51 +0000 (12:33 +0100)] 
Convert log-drop to packet logger api.

11 years agoTX logging API: convert HTTP log
Victor Julien [Thu, 5 Dec 2013 17:35:27 +0000 (18:35 +0100)] 
TX logging API: convert HTTP log

Convert the HTTP log to the new TX logging API.

11 years agoIntroduce TX logging API
Victor Julien [Thu, 5 Dec 2013 17:08:53 +0000 (18:08 +0100)] 
Introduce TX logging API

This patch introduces a new API for logging transactions from
tx-aware app layer protocols. It runs all the registered loggers
from a single thread module. This thread module takes care of the
transaction handling and flow locking. The logger just gets a
transaction to log out.

All loggers for a protocol will be run at the same time, so there
will not be any timing differences.

Loggers will no longer act as Thread Modules in the strictest sense.
The Func is NULL, and SetupOuputs no longer attaches them to the
thread module chain individually. Instead, after registering through
OutputRegisterTxModule, the setup data is used in the single logging
module.

The logger (LogFunc) is called for each transaction once, at the end
of the transaction.

11 years agoPacket logging API: convert unified2
Victor Julien [Thu, 5 Dec 2013 15:55:17 +0000 (16:55 +0100)] 
Packet logging API: convert unified2

Convert unified2 alert to new logging API.

11 years agoIntroduce packet logging output API
Victor Julien [Thu, 5 Dec 2013 14:35:15 +0000 (15:35 +0100)] 
Introduce packet logging output API

This patch introduces a new API for outputs that log based on the
packet, such as alert outputs. In converts fast-log to the new API.

The API gets rid of the concept of each logger being a thread module,
but instead there is one thread module that runs all packet loggers.
Through the registration function OutputRegisterPacketModule a log
module can register itself to be considered for each packet.

Each logger registers itself to this new API with 2 functions and the
OutputCtx object that was already used in the old implementation.
The function pointers are:

LogFunc:       the log function

ConditionFunc: this function is called before the LogFunc and only
               if this returns TRUE the LogFunc is called.

For a simple alert logger like fast-log, the condition function will
simply return TRUE if p->alerts.cnt > 0.

11 years agono-detect: handle protocols that have no logger 796/head
Victor Julien [Mon, 27 Jan 2014 13:36:15 +0000 (14:36 +0100)] 
no-detect: handle protocols that have no logger

If a protocol parser is active without a logger when detection is
disabled, the transaction handling logic would fail. Now it will
return the proper tx id so we can clean up the complete transactions.

11 years agoAdd --disable-detection configure option
Victor Julien [Mon, 6 Jan 2014 14:09:21 +0000 (15:09 +0100)] 
Add --disable-detection configure option

Add --disable-detection configure option to compile Suricata with
detection disabled.

11 years agoError out if -s/-S are used with disable detect
Victor Julien [Mon, 6 Jan 2014 13:09:35 +0000 (14:09 +0100)] 
Error out if -s/-S are used with disable detect

When Suricata is started with --disabled-detection, the -s and -S
options make no sense. So error out.

11 years agodetect-less: disable raw reassembly
Victor Julien [Tue, 17 Dec 2013 11:59:38 +0000 (12:59 +0100)] 
detect-less: disable raw reassembly

When using --disable-detection automatically disable raw stream
reassembly by forcing stream.reassembly.raw to be false.

11 years agodetect-less: add log only TX handling function
Victor Julien [Sat, 11 Jan 2014 10:14:56 +0000 (11:14 +0100)] 
detect-less: add log only TX handling function

When running w/o detect, TX cleanup handling needs to ignore the
inspect_id as it's only updated by detect.

This patch introduces a new ActiveTx handler for logging only:
AppLayerTransactionGetActiveLogOnly

If --disable-detection is passed on the commandline, this function
is registered.

11 years agoUpdate main loop to handle detect-less
Victor Julien [Mon, 16 Dec 2013 16:37:09 +0000 (17:37 +0100)] 
Update main loop to handle detect-less

Update main startup and shutdown loops to work will when detect
is disabled. In this case de_ctx remains NULL.

11 years agoupdate runmodes to handle detect-less
Victor Julien [Mon, 16 Dec 2013 16:35:27 +0000 (17:35 +0100)] 
update runmodes to handle detect-less

In runmodes setup, consider a NULL de_ctx to mean detect is disabled.

11 years agoflow-time: handle detect-less case
Victor Julien [Mon, 16 Dec 2013 16:32:13 +0000 (17:32 +0100)] 
flow-time: handle detect-less case

Flow timeout code keeps track of thread module running detect, and
fails (hard) if it doesn't find it.

This changeset retrieves the global g_detect_disabled and passes
it to the timeout handling code during setup.

11 years agoIntroduce g_detect_disabled global
Victor Julien [Mon, 16 Dec 2013 16:25:11 +0000 (17:25 +0100)] 
Introduce g_detect_disabled global

This global will be set to TRUE if detect is disabled. The reason for
adding a global is that there currently is no clean way to pass
configuration options to management threads.

11 years agoAdd --disable-detection commandline option
Victor Julien [Mon, 16 Dec 2013 14:56:49 +0000 (15:56 +0100)] 
Add --disable-detection commandline option

Flags the SuriInstance that the detection engine should be disabled.
Actual disabling is not yet implemented.

11 years agoflow-timeout: change error logic 795/head
Victor Julien [Fri, 24 Jan 2014 17:09:46 +0000 (18:09 +0100)] 
flow-timeout: change error logic

If FlowForceReassemblyForFlowV2 can't get packets to inject into the
engine, until now it would bail and retry later. In case of resource
starvation issues, this would cause a lot of lock contention, as the
flow manager would try over and over again.

This patch limits FlowForceReassemblyForFlowV2 to one try per flow,
if it fails... bad luck. It will only fail in serious conditions,
which means we must prefer the health of the engine over the proper
inspection of the flow in question.

11 years agoapp-layer-proto: speed up
Victor Julien [Fri, 24 Jan 2014 10:40:06 +0000 (11:40 +0100)] 
app-layer-proto: speed up

AppLayer Proto detection code uses a mix of pattern search and
"probing parsers". The pattern search validates potential matches
using a single pattern search algo. The code was using SpmSearch
for this, but this made it inefficient as it builds a BoyerMoore
context for each search. This lead to significant memory pressure,
especially on high speed/bandwidth boxes.

This patch switches the search calls to BoyerMoore and BoyerMoore-
Nocase directly. This can be done as the ctx' were available already.

11 years agoapp-layer-event: refactor
Victor Julien [Thu, 23 Jan 2014 08:55:09 +0000 (09:55 +0100)] 
app-layer-event: refactor

Move app layer event handling into app-layer-event.[ch].
Convert 'Set' macro's to functions.
Get rid of duplication in Set and SetRaw. Set now calls SetRaw.
Fix potentential int overflow condition in the event storage.
Update callers.

11 years agoapp-layer: shrink AppLayerParserState
Victor Julien [Thu, 23 Jan 2014 08:31:56 +0000 (09:31 +0100)] 
app-layer: shrink AppLayerParserState

Change layout to be more efficient, shrinks structure with 8 bytes.

11 years agostream: use reassembly.memcap for stream chunks
Victor Julien [Wed, 22 Jan 2014 20:15:43 +0000 (21:15 +0100)] 
stream: use reassembly.memcap for stream chunks

Use the stream.reassembly.memcap for stream chunks (StreaMsg) as well.

11 years agostream: in SACK, always decrease memcap on free
Victor Julien [Wed, 22 Jan 2014 18:14:19 +0000 (19:14 +0100)] 
stream: in SACK, always decrease memcap on free

We should always decrease the stream memcap on freeing SACK records.

11 years agopool: rename data structure fields to stack
Victor Julien [Wed, 22 Jan 2014 15:43:38 +0000 (16:43 +0100)] 
pool: rename data structure fields to stack

Rename the following fields:
 -    uint32_t alloc_list_size;
 +    uint32_t alloc_stack_size;

 -    PoolBucket *alloc_list;
 +    PoolBucket *alloc_stack;

 -    PoolBucket *empty_list;
 -    uint32_t empty_list_size;
 +    PoolBucket *empty_stack;
 +    uint32_t empty_stack_size;

To reflect that these are in fact, stacks.

11 years agopool: remove tail tracking in alloc list
Victor Julien [Wed, 22 Jan 2014 15:30:50 +0000 (16:30 +0100)] 
pool: remove tail tracking in alloc list

The list fully acts like a stack now.

11 years agopool: document some of the Pool:: fields.
Victor Julien [Wed, 22 Jan 2014 15:24:02 +0000 (16:24 +0100)] 
pool: document some of the Pool:: fields.

11 years agopool: update internal counters at the proper time
Victor Julien [Wed, 22 Jan 2014 14:32:18 +0000 (15:32 +0100)] 
pool: update internal counters at the proper time

Only update Pool::outstanding and Pool::allocated in PoolGet when
we are sure both Alloc and Init were successful.

11 years agostream: improve memcap checking
Victor Julien [Wed, 22 Jan 2014 09:59:31 +0000 (10:59 +0100)] 
stream: improve memcap checking

Only the TcpSegment structure would be checked for fitting in the
memcap, not the actual data.

11 years agostream: cast memcap checks to uint64_t
Victor Julien [Wed, 22 Jan 2014 08:36:28 +0000 (09:36 +0100)] 
stream: cast memcap checks to uint64_t

11 years agoapp-layer: parser cleanup 790/head
Victor Julien [Fri, 17 Jan 2014 16:01:37 +0000 (17:01 +0100)] 
app-layer: parser cleanup

Use f->protomap instead of calling FlowGetProtoMapping. Don't use
TcpSession *ssn ptr for anything other than TCP

11 years agodetect: use pflow pointer
Victor Julien [Fri, 17 Jan 2014 13:58:14 +0000 (14:58 +0100)] 
detect: use pflow pointer

Use pflow pointer in SigMatchSignatures consistently. Also, when
needing access to the ipproto, use p->proto, not p->flow->proto.

11 years agoapp-layer proto detect: optimization
Victor Julien [Fri, 17 Jan 2014 12:49:10 +0000 (13:49 +0100)] 
app-layer proto detect: optimization

Don't use FlowGetProtoMapping at runtime, use f->protomap instead.
Add safety check to make sure its value is within range, as it's
used to index an array.

Update unittests to initialized flows (somewhat).

11 years agoCoverity 1153935: fix confusing sizeof
Victor Julien [Fri, 17 Jan 2014 10:57:51 +0000 (11:57 +0100)] 
Coverity 1153935: fix confusing sizeof

11 years agoApp-layer proto detect cleanups
Victor Julien [Fri, 17 Jan 2014 08:55:46 +0000 (09:55 +0100)] 
App-layer proto detect cleanups

Remove unnecessay inlining.
Rename functions with wrong naming scheme. E.g. AllocAppLayer.. instead
of AppLayer..Alloc.
Use AppProto instead of uint16_t.
Convert u16 ipproto cases to u8.

11 years agodns: add event for when memcap is reached 789/head
Victor Julien [Tue, 21 Jan 2014 13:51:56 +0000 (14:51 +0100)] 
dns: add event for when memcap is reached

Raise event if state-memcap is reached for a flow.

11 years agodns: update counters 788/head
Victor Julien [Tue, 21 Jan 2014 13:18:37 +0000 (14:18 +0100)] 
dns: update counters

This patch updates the DNS counters from the main AppLayer entry
functions. Due to the limited scope of AppLayerThreadCtx some of
the logic had to be implemented in app-layer.c, where it doesn't
belong.

11 years agodns: register counters
Victor Julien [Tue, 21 Jan 2014 12:22:48 +0000 (13:22 +0100)] 
dns: register counters

Register dns memory counters.
Keep track of memcap reached conditions, and increment counters for
those.

11 years agoapp-layer: update UDP entry function
Victor Julien [Tue, 21 Jan 2014 12:50:38 +0000 (13:50 +0100)] 
app-layer: update UDP entry function

Update AppLayerHandleUdp to take the ThreadVars pointer as an
argument in prepraration of handling counters in this function.

11 years agoPass ThreadVars ptr to various thread init funcs
Victor Julien [Tue, 21 Jan 2014 12:42:10 +0000 (13:42 +0100)] 
Pass ThreadVars ptr to various thread init funcs

To be able to register counters from AppLayerGetCtxThread, the
ThreadVars pointer needs to be available in it and thus in it's
callers:

- AppLayerGetCtxThread
- DecodeThreadVarsAlloc
- StreamTcpReassembleInitThreadCtx

11 years agodns: add memcap checking 787/head
Victor Julien [Tue, 21 Jan 2014 11:01:07 +0000 (12:01 +0100)] 
dns: add memcap checking

Add memuse tracking and memcap checking to the DNS parsers. Memuse
is tracked globally and per flow (state).

Memcaps are also checked per flow and globally before memory allocs
are done.

11 years agodns: make DNSTransactionAlloc static
Victor Julien [Tue, 21 Jan 2014 09:58:51 +0000 (10:58 +0100)] 
dns: make DNSTransactionAlloc static

11 years agodns: add memcap options
Victor Julien [Tue, 21 Jan 2014 09:39:50 +0000 (10:39 +0100)] 
dns: add memcap options

Add per state and global memcap option parsing.

11 years agodns: fix dns configure code
Victor Julien [Tue, 21 Jan 2014 09:27:28 +0000 (10:27 +0100)] 
dns: fix dns configure code

Yaml layout changed. DNS had to be updated to retrievel value
for dns flood from the correct location in the config tree.

11 years agoBug 1083 and 1084: add valgrind suppressions 786/head
Victor Julien [Mon, 20 Jan 2014 13:06:11 +0000 (14:06 +0100)] 
Bug 1083 and 1084: add valgrind suppressions

Add suppressions as these are minor issues and likely not bugs in
Suricata.

11 years agoapp-layer-ssl: fix unusual memory leak
Victor Julien [Mon, 20 Jan 2014 11:42:59 +0000 (12:42 +0100)] 
app-layer-ssl: fix unusual memory leak

In some cases the TLS state pointers to subject and issuerdn could
be overwritten by a new memory allocation, causing us to loose
track of the old.

This has been observed in the case of improper VLAN handling, where
it was suspected that multiple unrelated TLS streams were mangled
together.

11 years agoapp-layer-ssl: style fixes
Victor Julien [Mon, 20 Jan 2014 09:49:55 +0000 (10:49 +0100)] 
app-layer-ssl: style fixes

Coding style fixes for TLS handshake parser.

11 years agoapp-layer-ssl: code cleanup
Victor Julien [Mon, 20 Jan 2014 09:42:12 +0000 (10:42 +0100)] 
app-layer-ssl: code cleanup

Don't alloc a void ptr and then cast in every operation. Instead,
alloc a SSLState ptr and only case to void on returning the ptr.

11 years agoutil-device: use safe tailq foreach 784/head
Eric Leblond [Mon, 20 Jan 2014 09:41:28 +0000 (10:41 +0100)] 
util-device: use safe tailq foreach

The loop is freeing elements so we need to use the safe version
of TIALQ_FOREACH.

This fixes a valgrind error:

 Thread 1 Suricata-Main:
 Invalid read of size 8
    at 0x8E129C: LiveDeviceListClean (util-device.c:167)
    by 0x89B742: main (suricata.c:2284)
  Address 0x8382988 is 24 bytes inside a block of size 40 free'd
    at 0x4C2A70C: free (vg_replace_malloc.c:468)
    by 0x8E1297: LiveDeviceListClean (util-device.c:179)
    by 0x89B742: main (suricata.c:2284)

11 years agoBug 980: fix HTTP memory cleanup at shutdown
Victor Julien [Fri, 17 Jan 2014 17:58:21 +0000 (18:58 +0100)] 
Bug 980: fix HTTP memory cleanup at shutdown

Buffers in per thread HTTP header, client body and server body storage
would be freed based on the usage indicator instead of the size
indicator.

As the usage indicator (e.g. hsbd_buffers_list_len) could be reset
while leaving the memory untouched for later reuse, the free function
would not iterate over all memory blocks.

Removed DrMemory suppressions as well.

Bug #980.

11 years agoaf-packet: fix problem introduced in recent commit 780/head
Eric Leblond [Fri, 17 Jan 2014 16:43:50 +0000 (17:43 +0100)] 
af-packet: fix problem introduced in recent commit

Logic of patch 98e4a14f6d59fe8928fd6e2af3d9c3e8b42d00bf was correct
but implementation is wrong because TP_STATUS_KERNEL is equal to
zero and thus can not be evaluated in a binary operation. This patch
updates the logic by doing two tests.

Reported-by: Alessandro Guido
11 years agoRemove BUG_ON(1) in app layer event second stage preparation function.
Anoop Saldanha [Sat, 11 Jan 2014 15:08:40 +0000 (20:38 +0530)] 
Remove BUG_ON(1) in app layer event second stage preparation function.

This lets us single out and print rules that result in a failure, than
just post a core dump.

11 years agoFix make distcheck for Tile
Ken Steele [Tue, 14 Jan 2014 17:38:15 +0000 (12:38 -0500)] 
Fix make distcheck for Tile

src/Makefile.am was missing util-mpm-ac-tile-small.c which caused
release tarballs for fail to build on Tile-Gx.

11 years agoFix crash in AppLayer Proto Detect 778/head
Victor Julien [Fri, 17 Jan 2014 09:18:32 +0000 (10:18 +0100)] 
Fix crash in AppLayer Proto Detect

The App Proto Detect code would use the wrong pattern count to
index a results array, leading to SEGVs.

Bug #1080.

11 years agoCygwin: make configure pass with -Werror 773/head
Victor Julien [Mon, 16 Dec 2013 13:41:46 +0000 (14:41 +0100)] 
Cygwin: make configure pass with -Werror

11 years agoCygwin: fix compilation
Victor Julien [Mon, 16 Dec 2013 12:53:51 +0000 (13:53 +0100)] 
Cygwin: fix compilation

tm-threads.c:1190:5: error: unknown type name ‘DWORD’

11 years agoFix compiler warning:
Victor Julien [Mon, 16 Dec 2013 12:29:06 +0000 (13:29 +0100)] 
Fix compiler warning:

array subscript has type ‘char’ [-Werror=char-subscripts]

11 years agoFix coccinelle autotools check 771/head
Victor Julien [Tue, 14 Jan 2014 13:57:42 +0000 (14:57 +0100)] 
Fix coccinelle autotools check

11 years agococcinelle: add --disable-coccinelle to configure 770/head
Victor Julien [Tue, 14 Jan 2014 12:41:09 +0000 (13:41 +0100)] 
coccinelle: add --disable-coccinelle to configure

This allows disabling of the expensive cocci QA checks during
QA.

11 years agopool thread: undo CLS alignment
Victor Julien [Tue, 14 Jan 2014 12:03:43 +0000 (13:03 +0100)] 
pool thread: undo CLS alignment

This breaks clang on 32bit.

Test PoolThreadTestGrow01                                         : process killed by signal 11

11 years agoFix unittest size_t printing on 32bit
Victor Julien [Tue, 14 Jan 2014 10:48:25 +0000 (11:48 +0100)] 
Fix unittest size_t printing on 32bit

11 years agodns: tag each tx we get a reply for as replied 765/head
Victor Julien [Thu, 12 Dec 2013 12:12:13 +0000 (13:12 +0100)] 
dns: tag each tx we get a reply for as replied

Also, detect and print when server says recursion is desired.

11 years agoDNS: don't store duplicate queries
Victor Julien [Sat, 7 Dec 2013 10:41:45 +0000 (11:41 +0100)] 
DNS: don't store duplicate queries

When an exact duplicate DNS query is received, don't store it in the
tx.

11 years agomemcmp: convert all pointer arguments to be const pointers, like memcmp itself uses.
Victor Julien [Sat, 7 Dec 2013 10:29:22 +0000 (11:29 +0100)] 
memcmp: convert all pointer arguments to be const pointers, like memcmp itself uses.

11 years agodns log: cleanups
Victor Julien [Fri, 6 Dec 2013 13:43:15 +0000 (14:43 +0100)] 
dns log: cleanups

11 years agoapp-layer: API calls to check for TX aware proto
Victor Julien [Fri, 10 Jan 2014 12:02:19 +0000 (13:02 +0100)] 
app-layer: API calls to check for TX aware proto

Introduce AppLayerParserProtocolIsTxAware which returns 1 if protocol
is Tx aware, 0 if not.

11 years agoRemove GCC -no-strict-aliasing compiler flag. 764/head
Ken Steele [Fri, 10 Jan 2014 17:36:02 +0000 (12:36 -0500)] 
Remove GCC -no-strict-aliasing compiler flag.

GCC typically generates better code without the -no-strict-aliasing flag.
It is only required if code makes assumptiosn that break strict aliasing.
The unit tests pass on x86 and Tile without the flag.

11 years agoFix PmqSetup() argument removal in ac-tile MPM unit tests.
Ken Steele [Fri, 10 Jan 2014 15:40:52 +0000 (10:40 -0500)] 
Fix PmqSetup() argument removal in ac-tile MPM unit tests.

Needed to remove the second argument from all the calls, which was always 0
and was removed in other tests in a previous checkin.

11 years agocounters: fix 2 scan-build warnings
Victor Julien [Thu, 19 Dec 2013 20:14:06 +0000 (21:14 +0100)] 
counters: fix 2 scan-build warnings

counters.c:1069:13: warning: Potential leak of memory pointed to by 'temp'
            SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./threads.h:121:28: note: expanded from macro 'SCMutexUnlock'
                           ^~~~~~~~~~~~~~~~~~~~
counters.c:1156:16: warning: Potential leak of memory pointed to by 'pca'
        return NULL;
               ^~~~
/usr/include/clang/3.3/include/stddef.h:77:24: note: expanded from macro 'NULL'
                       ^
2 warnings generated.

11 years agoapp-layer: configurable GetActiveTxId function 762/head
Victor Julien [Mon, 9 Dec 2013 16:41:22 +0000 (17:41 +0100)] 
app-layer: configurable GetActiveTxId function

In preparation of a patchset that will allow for disabling the detect
module, this patch introduces a way to register a function for getting
the lowest active tx id. This is used by the app layer for cleaning up
transactions that already fully inspected, and by the flow timeout code
to determine if a flow is fully inspected and logged at timeout.

The registration function RegisterAppLayerGetActiveTxIdFunc allows for
registration of a custom function of type:
  uint64_t (*GetActiveTxIdFunc)(Flow *f, uint8_t flags);

If no function is called, AppLayerTransactionGetActiveDetectLog is used,
which implements the existing behaviour of considering both the
inspect_id's and the log_id.

11 years agoClean up TX clean up
Victor Julien [Mon, 9 Dec 2013 14:56:43 +0000 (15:56 +0100)] 
Clean up TX clean up

In AppLayerTransactionsCleanup instead of figuring out 'done' tx id's
itself, now call AppLayerTransactionGetActive for both directions to
figure out the completed TX id's.

11 years agostream: don't send empty streammsg at stream end 759/head
Victor Julien [Wed, 18 Dec 2013 08:14:20 +0000 (09:14 +0100)] 
stream: don't send empty streammsg at stream end

No longer send an empty StreamMsg through the engine on stream end,
the messages were ignored anyway.

11 years agostream: increase max StreamMsg data
Victor Julien [Tue, 17 Dec 2013 19:56:58 +0000 (20:56 +0100)] 
stream: increase max StreamMsg data

Increase from 4024 bytes to 4072 to make the whole structure
4096 again.

11 years agostream: remove flags from StreamMsg
Victor Julien [Tue, 17 Dec 2013 19:52:38 +0000 (20:52 +0100)] 
stream: remove flags from StreamMsg

11 years agostream: remove per thread queue for stream msgs
Victor Julien [Tue, 17 Dec 2013 15:57:48 +0000 (16:57 +0100)] 
stream: remove per thread queue for stream msgs

StreamMsgs would be stored in a per thread queue before being
attached to the tcp ssn. This is unnecessary, so this patch
removes this queue and puts the smsgs into the ssn directly.

Large patch as it affects a lot of tests.

11 years agostream: remove flow reference from StreamMsg
Victor Julien [Tue, 17 Dec 2013 15:33:26 +0000 (16:33 +0100)] 
stream: remove flow reference from StreamMsg

StreamMsg' flow reference was used mostly to make sure a flow would
not get removed from the hash before inspection. For this it needed
to reference the flow use_cnt reference counter. Nowadays we have
more advanced flow timeout handling. This will make sure that if
there still are pending smsgs' in a flow, these will still be
processed.

11 years agostream: pass TcpSession to StreamTcpReassembleProcessAppLayer
Victor Julien [Tue, 17 Dec 2013 15:19:16 +0000 (16:19 +0100)] 
stream: pass TcpSession to StreamTcpReassembleProcessAppLayer

Preparation for removing flow pointer from StreamMsg. Instead of
getting the ssn indirectly through StreamMsg->flow, we pass it
directly as all callers have it already.

11 years agostream msg: remove structure
Victor Julien [Tue, 17 Dec 2013 14:54:09 +0000 (15:54 +0100)] 
stream msg: remove structure