Commit Graph

6169 Commits (c06dfe6e26e16b0c8e3d4965b5a0ddafc2553174)
 

Author SHA1 Message Date
cardigliano c06dfe6e26 pfring pkt acq: keep running on 'pfring_set_cluster' failure when cluster is not required
Suricata creates a pfring cluster with a default ID = 1 when not explicitly configured,
unless the device has prefix 'dna' or 'zc'. Since pf_ring also supports other cards
implementing kernel-bypass (cluster not supported), this is preventing those cards from
running on top of this module. This patch stops suricata on 'pfring_set_cluster' failure
only when error code != PF_RING_ERROR_NOT_SUPPORTED or cluster ID has not been explicitly
configured.
9 years ago
Victor Julien 7f8795c756 threading: avoid autofp deadlock
When there are many threads and/or the packet pool (max-pending-packets) is
small, a potential dead lock exists between the packet pool return pool
logic and the capture threads. The autofp workers together can have all the
packets in their return pools, while the capture thread(s) are waiting at an
empty pool. A race between the worker threads and the capture thread, where
the latter signals the former, is lost by the capture thread. Now everyone
is waiting.

To avoid this scenario, this patch makes the previously hardcoded 'return
pool' threshold dynamic based on the number of threads and the packet pool
size.

It sets the threshold to the max pending packets value, divided by the number
of lister threads. The max value hasn't changed. Normally, in the autofp
runmode these are the stream/detect/log worker threads.

The max_pending_return_packets value needs to stay below the packet pool size
of the 'producers' (normally pkt capture threads but also flow timeout
injection) to avoid the deadlock.

As it's quite impossible at this time to learn how many threads will be
created before starting the runmodes, and thus spawning the threads and
already initializing the packet pools, this code sets a global variable
after runmode setup, but before the threads are 'unpaused'.
9 years ago
Victor Julien 8d06d7bccc threads: add func to count running threads of types 9 years ago
Victor Julien ca3916881f threading: store thread module flags in threadvars 9 years ago
Victor Julien 77624701e7 htp: cleanup, remove unused declaration 10 years ago
cardigliano 86711a1332 pfring pkt acq: capture loop optimisation
For each packet the capture module checks whether it is time to dump stats calling
TimeGet(). TimeGet() is an expensive function using gettimeofday() or SCSpinLock()
which affect performance. Since gettimeofday() is already called for setting packet
timestamp, it is more efficient to use the packet timestamp directly.
10 years ago
cardigliano 70c98c1ff2 pfring pkt acq: removed reentrant flag
PF_RING_REENTRANT is not needed as each pfring socket is used by a single thread.
10 years ago
cardigliano c4850c1d8f pfring pkt acq: use zero-copy recv in workers runmode
This patch removes packet copy when suricata is running in workers runmode,
packet copy is not needed in this case since packets are processed in sequence.
10 years ago
Eric Leblond d88e133428 util-logopenfile: don't allocate redis command
As we only have two different commands we don't need to allocate
it and can use pointer to global variables.
10 years ago
Eric Leblond 2ea4bbc492 util-logopenfile: move sensor_name to filectx
We will now output the sensor name independantly of the output
method if it is set in the YAML file. In the case of redis we are
using the hostname value if unset.
10 years ago
Eric Leblond 7e3a5a0db2 util-logopenfile: log queued events at exit
Do a redis query at exit to log possibly existing events.
10 years ago
Eric Leblond 404e660410 util-logopenfile: don't lock syslog write 10 years ago
Eric Leblond c5d939834f util-logopenfile: cleaner free function 10 years ago
Eric Leblond 1b0f2774f2 util-logopenfile: don't use atomic for batch_count 10 years ago
Eric Leblond e9d26dd510 util-logopenfile: use a function for redis write 10 years ago
Eric Leblond f11b269ef1 redis-output: fix sensor-name code
The sensor-name was not freed at exist and the result of SCStrdup
was not checked.
10 years ago
Eric Leblond 594f62b523 util-logopenfile: reconnect handling
This patch implements reconnection handling for the redis output.
A reconnect limitation has been implemented with a limitation of
one connection per second.
10 years ago
Eric Leblond b834e2d19a util-logopenfile: implement redis pipelining
This patch implements redis pipelining. This consist in contacting
the redis server every N events to minimize the number of TCP
exchange. This is optional and setup via the configuration file.
10 years ago
Eric Leblond f953fdfbac util-logopenfile: introduce SCConfLogOpenRedis
Introduce a function to realize the parsing and config file and
opening of connection to the database. Only used by output-json
for now it will be usable by other logging modules.
10 years ago
Eric Leblond a13be67b5e util-logopenfile: add write function
Introduce a function LogFileWrite that will handle the writing with
respect of the type defined in the configuration. This is used in
this patch to remove the write complexity from output-json.
10 years ago
Eric Leblond 60ea49c777 output-json: add sensor-name config variable
When using redis output, we are loosing the host key (added by
logstash or logstash-forwarder) and we can't find anymore what
Suricata did cause the alert.

This patch is adding this key during message generation using the
'sensor-name' variable or the hostname is 'sensor-name' is not
defined.
10 years ago
Eric Leblond 9286360f86 travis: add libjansson and hiredis
Install the libs and force usage of hiredis. We will have a more
complete build with this two libs.
10 years ago
Eric Leblond 31c91d53bb output-json: improve hiredis define
Use #ifdef instead of #if and don't include the header which is
not needed anymore.
10 years ago
Eric Leblond eef5678e5e output-json: add redis support
This patch adds redis support to JSON output.
10 years ago
Giuseppe Longo 769722101e decode: add flow memcap counter
This adds a counter indicating how many times
the flow max memcap has been reached

Since there is no always a reference to FlowManagerThreadData,
the counter is put in DecodeThreadVars.

Currently when there is no counter increase in one call of FlowGetNew
because we don't have tv or dtv at the time of the call.

The following is a snippet of the generated EVE entry:
"flow":{"memcap":0,"spare":10000,"emerg_mode_entered":0,"emerg_mode_over":0,"tcp_reuse":0,"memuse":7085248}
10 years ago
cardigliano c2704c3933 workers runmode: allow multiple input devices
This fix allows multiple input devices when running in 'workers' mode.
10 years ago
Eric Leblond 16b210f1ea json-file: avoid allocation 10 years ago
Eric Leblond f8b6768d05 json-email: fix coverity alert
The code was not correct and coverity did detect a potential
overflow problem that should not happen because of the structure
of md5 string and of format.
10 years ago
Jason Ish dc2c896781 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.
10 years ago
Jason Ish 9697a09d21 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.
10 years ago
Eric Leblond 38c21077e6 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.
10 years ago
Eric Leblond 3676bd667d json-email-common: suppress commented code 10 years ago
Eric Leblond 484885b70f 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.
10 years ago
Torgeir Natvig af6d1dddfa Bugfix for detect-engine.luajit-states
detect-engine is a list, and luajit-states was looked up as a map.
10 years ago
Mats Klepsland 70cc1ddbcd lua: SSH output support
Support SSH in lua output scripts (Feature #1569).
10 years ago
Mats Klepsland 7eab16c478 lua: SSH support
Support SSH in lua detection scripts (Feature #1569).
10 years ago
Alessandro Guido dcbbda505f Describe new unified2-alert "payload" option 10 years ago
Alessandro Guido 53bfcf64b7 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.
10 years ago
Jason Ish 413082afc0 GPL license sync with official gpl-2.0.txt
Synced up with:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
10 years ago
Jason Ish 580728087c 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.
10 years ago
Jason Ish 4185f3ee92 detect-pcre: allow upper cases metachars for host (/W).
Redmine issue 1490.
10 years ago
Eric Leblond 6572725a7a 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.
10 years ago
Victor Julien 4d83318b46 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
10 years ago
Jason Ish 6f223c6dba defrag: stop reassembly at the first packet with more flags not set 10 years ago
Jason Ish 3aa7e38c14 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.
10 years ago
Jason Ish 69b4218afc 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.
10 years ago
Jason Ish ed400acf8e defrag: unit test for tracker reuse (current fails)
Will be fixed in subsequent commits as tracker reuse is fixed.
10 years ago
Alexander Gozman 3e29a23208 unix-manager: log client (dis)connection with DEBUG level.
Also select/receive errors are logged as ERROR.
10 years ago
Alexander Gozman 437fe40660 Feature 1527: ability to compile as a position independent executable
Adds corresponding configure option which enables proper CPPFLAGS
and LDFLAGS.
10 years ago
Mats Klepsland e634fcee60 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
10 years ago