Commit Graph

4929 Commits (238ff23111f78073c4ebefe9fc1de72ea54a74d3)
 

Author SHA1 Message Date
Ken Steele 1f99096b30 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 ago
Victor Julien 399246881d 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 ago
Victor Julien 2c857087fb 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 ago
Victor Julien c06c595c56 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 ago
Victor Julien 6e389a1fbb 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 ago
Victor Julien eb1f5ce358 stream: increase max StreamMsg data
Increase from 4024 bytes to 4072 to make the whole structure
4096 again.
11 years ago
Victor Julien c801ef3515 stream: remove flags from StreamMsg 11 years ago
Victor Julien 261881fce2 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 ago
Victor Julien b159c1714c 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 ago
Victor Julien 1d08a3ff26 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 ago
Victor Julien 0ec375d95a stream msg: remove structure 11 years ago
Victor Julien 5ca0139cbc stream: remove unused gap structure from StreamMsg. 11 years ago
Victor Julien 3804f3f1b3 stream: no longer process STREAM_GAP smsgs
StreamSmgs are used for raw stream reassembly only. They could also
be used to tell the rest of the engine about sequence gaps. This was
a left over from the older implementation, where the app layer used
the smsgs as well.
11 years ago
Jason Ish 5850607fea Remove the old include support. 11 years ago
Ken Steele 3a9a14711a Correct coding style in decode-ethernet.c
This file is given as the example of correct coding style, so make sure it
follows the coding standard.
11 years ago
Eric Leblond 7561da4b87 debug: default logging level is notice
Update the string in message because default logging level is
now notice and not info.
11 years ago
Eric Leblond d6932f90db doxygen: document some functions 11 years ago
Eric Leblond 1512d43dec doxygen: document all code
This patch update doxygen configuration to have all possible functions
documented (even the one without doxygen formated comments). It can be
really useful to have that in case we are trying to get some information
on call graph for example.
11 years ago
Eric Leblond d2fe368200 doxygen: add profiling to generated doc.
Profiling code needs the PROFILING define to be documented.
11 years ago
Eric Leblond e5e390a0c6 Add missing UNITTESTS
There is no need for test functions to be build in normal code.
11 years ago
Eric Leblond 98e4a14f6d af-packet: update packet reading loop logic
This patch updates the logic of the packet acquisition loop. When
the reader loop function is called and when the data to read
at offset is a without data (kernel) or still used by suricata. We
try to iter for a loop on the ring to try to find kernel put by
data.
As we are entering the function because the poll said there was some
data. This allow us to jump to the data added to the ring by the
kernel.
When using suricata in autofp mode, with multiple detect threads and
packet acquisition threads attached to a dedicated CPU, the reader
loop function was looping really fast because poll call was returning
immediatly because we did read the data available.
11 years ago
Eric Leblond 55108167e5 prscript: add --norebase option
If --norebase option is provided, the prscript will start a build
that can be used to check if an out-of-sync branch pass the test.
11 years ago
Eric Leblond 4d6b48ea9e htp layer: add memory cap counter
This patch adds a memcap counter for HTP memory usage. Counter
is increased each time an allocation is not done due to the memcap.
11 years ago
Eric Leblond d6d8a08a8f htp layer: add memory usage counter
This patch adds a memory counter for HTP memory usage. As
there is no thread variables available in application layer
the counter has been added to the TCP reassembly thread.
11 years ago
Eric Leblond ced01da822 htp layer: use memcap for HTTP related allocations
This patch introduces wrapper functions around allocation functions
to be able to have a global HTP memcap. A simple subsitution of
function was not enough because allocated size needed to be known
during freeing and reallocation.

The value of the memcap can be set in the YAML and is left by default
to unlimited (0) to avoid any surprise to users.
11 years ago
Ken Steele ba4758d033 Port unittest from bug #970 for util-mpm-ac.c to util-mpm-ac-tile.c
Passes on ac-tile too.
11 years ago
Ken Steele 326d5d3e15 Add 8-bit states to ac-tile
When running with sgh-mpm-context: full, many more MPMs are created
(16K) and many are small. If they have less than 128 states, they only
need 1 byte for the next state instead of 2 bytes, cutting the size of
the next-state table in half. This reduces total memory usage.

Since that makes 3 different state sizes (1, 2 and 4 bytes), rather
than going from 2 copies of the code to create the MPM to 3, I
factored out the code that fills the next-state table into three
functions so that all the other code could be the same.

The search function is now parameterize for 8-bit and 16-bit state
sizes and alphabet sizes 8, 16, 32, 64, 128 and 256.
11 years ago
Eric Leblond c115e63dc2 pfring: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by pfring. This patch fixes
this by using counter provided by kernel instead.

Pfring kernel counter is per socket and is not cleared after read.
So to get the number of packet on the interface we can add the new
value for this thread and add it to the interface counter.
11 years ago
Eric Leblond 1869688fb8 af-packet: fix live device counter usage
Live device counter was in fact the number of packets seen by suricata
and not the total number of packet reported by kernel. This patch fixes
this by using counter provided by kernel instead.
The counter is Clear On Read, so by adding the value fetch at each call
and earch sockets we get the number of packets and drops for the
interface.
11 years ago
Eric Leblond afbb2eb32b capture: display exit stats at default verbosity
This patch updates capture modes not using LiveDecice counters
to display per-thread exit statistics with default verbosity.
11 years ago
Eric Leblond a8c787a265 device list: clean and display stat at exit
This patch adds a cleaning function to device list. This also
permits to display per-interface statistics during the exit.
11 years ago
Duarte Silva aa6b5b406d Fix the segmentation fault while logging the host on the custom HTTP logger.
- Seems to be a regression introduced in the commit
  796bfab231 (fix was already done in commit
  ee0b21652b)
- Doesn't happen with htplib v0.5.6, but it does in the latest, v0.5.9
11 years ago
Eric Leblond 7cc87bc02a coccinelle: protecting regexp operator is not needed
It seems there was an evolution of coccinelle and the protection
of regexp is not necessary anymore. And doing it causing the
expression not to match.
11 years ago
Eric Leblond 8a5a30ba40 fix size_t printing
This two problem were found by the new version of the size_t cocci
test.
11 years ago
Victor Julien 446e68adca app-layer: only typedef opaque pointers once 11 years ago
Victor Julien 3b8e9ffbe9 app layer: void -> AppLayerProtoDetectThreadCtx
User AppLayerProtoDetectThreadCtx ptr instead of void.
11 years ago
Victor Julien 8dbf7a0d78 Update tests to use AppLayerParserThreadCtx ptr instead of void. Fix a few bugs uncovered by this. 11 years ago
Victor Julien 9634e60e7a app-layer: Use opaque pointers instead of void
For AppLayerThreadCtx, AppLayerParserState, AppLayerParserThreadCtx
and AppLayerProtoDetectThreadCtx, use opaque pointers instead of
void pointers.

AppLayerParserState is declared in flow.h as it's part of the Flow
structure.

AppLayerThreadCtx is declared in decode.h, as it's part of the
DecodeThreadVars structure.
11 years ago
Victor Julien c7ae662d26 Fix HTPBodyReassemblyTest01 Asan error
Fix improper pointer assignment in HTPBodyReassemblyTest01, causing
ASAN to error out.
11 years ago
Victor Julien fdefb65be4 app-layer: rename AppLayerThreadCtx funcs
AppLayerParserGetCtxThread -> AppLayerParserThreadCtxAlloc
AppLayerParserDestroyCtxThread -> AppLayerParserThreadCtxFree
11 years ago
Victor Julien 0bac43a1ca app layer: fix memory leak
Actually free the ctx in AppLayerParserDestroyCtxThread
11 years ago
Victor Julien f5f148805c app layer: uint16_t alproto -> AppProto alproto
This conversion was missing in a couple of places.
11 years ago
Victor Julien 5cdeadb33d Use u8 for ipproto
In a few places in app layer and unittests u16 was used.
11 years ago
Victor Julien 8527b8e08e App Layer: cleanup state func naming
Rename functions related to AppLayerState to be more consistent.
11 years ago
Victor Julien 30f16ee446 Rename AppLayerProtoDetectCtxThread -> AppLayerProtoDetectThreadCtx 11 years ago
Victor Julien cd0627cd39 Rename AppLayerParserParserState -> AppLayerParserState 11 years ago
Victor Julien c23742a0a7 Rename AppLayerParserpCtx -> AppLayerParserProtoCtx 11 years ago
Victor Julien 72a1645979 Rename AppLayerParserCtxThread -> AppLayerParserThreadCtx 11 years ago
Victor Julien ac77cd790f Rename AppLayerCtxThread -> AppLayerThreadCtx 11 years ago
Victor Julien e111401c10 detect unittests: clang build fix and cleanups
A number of unittests would lead to clang build errors because
of unsafe det_ctx ptr usage. This patch fixes these and inits
det_ctx to NULL in the other detect tests.
11 years ago