Commit Graph

5170 Commits (033ad9e97429d0f01b3601c9b3a30dae4c5d9acc)
 

Author SHA1 Message Date
Alexander Gozman c770ade9c2 Changed variable name when dumping single packet 11 years ago
Alexander Gozman 2a4c7ee5dc Add ability to encode payload in Base64 11 years ago
Alexander Gozman ffac6b71e2 Fixed stream handling Fixed some coding style issues 11 years ago
Matt Carothers ab58ee2676 Add packet and payload logging to JSON alert output 11 years ago
Victor Julien c53b428079 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 ago
Victor Julien c4a8e2cd14 Remove unused variables 11 years ago
Victor Julien 1d9278bef4 Fix packet pool pending stack adds
Add packets after the first as the list/stack head as well.
11 years ago
Victor Julien b5d3b7e92a 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 ago
Ken Steele 0dd16461cf Update max-pending-packet comments to show it is now per-thread.
Updated suricata.yaml and comments in the code.
11 years ago
Ken Steele 28ccea51d3 Add error checking for pthread_setspecific() and pthread_key_create(). 11 years ago
Ken Steele b1a7e76ca7 Use posix_memalign instead of mm_malloc on non-Windows systems. 11 years ago
Ken Steele a38d5a0135 Implement thread specific data option when __thread is not available. 11 years ago
Ken Steele be448aef22 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 ago
Ken Steele 3c6e01f653 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 ago
Victor Julien 94571c5dd2 AC: shrink output table after initialization 11 years ago
Victor Julien 04c9db398e AC: reduce realloc for new states
Don't realloc per state add, but grow by larger blocks per realloc.
11 years ago
Ken Steele ba1e2ed69d 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 ago
Ken Steele 967f7aefde 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 ago
Ken Steele 54214d1251 Fix comment wording in Boyer Moore pattern matcher. 11 years ago
Eric Leblond de6dac0043 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 ago
Victor Julien 9ec23bd593 pcap log: document multi option
Add yaml documentation for new 'multi' option.
11 years ago
Victor Julien be1979b2f9 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 ago
Victor Julien 6cebe7ef7b 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 ago
Victor Julien 923341fa05 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 ago
Victor Julien 4922cd2d36 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 ago
Victor Julien bbc8c1ea05 log-pcap: multi mode yaml parsing
In preparation of the multi file mode, add 'multi' as a value to
the mode.
11 years ago
Victor Julien cf4db47931 log-pcap: lock profiling
Add lock profiling to pcap logging profiling.
11 years ago
Victor Julien adde58d2cb 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 ago
Victor Julien f6c5b1715f Update log-pcap.h, add license
Clean up log-pcap.h and add the OISF license header.
11 years ago
Victor Julien 1af2f6528b log-pcap code cleanups
Code cleanups to make functions static.
11 years ago
Victor Julien fd7dd09f4c 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 ago
Victor Julien ed84c8795d Update version number to 2.1dev 11 years ago
Victor Julien d258a11f0d autotools: enable silent mode
Add check to make sure that if the functionality isn't available, we
don't error out.
11 years ago
Victor Julien cba043da39 Open 2.1 development in the master branch. 11 years ago
Victor Julien 2646edc129 Profiling: fix compilation on CentOS5
Bug #1207
11 years ago
Victor Julien f232fdc0c9 htp: init memuse atomics
In case of the spinlocked fallback code the lock was uninitialized.
11 years ago
Victor Julien f06e5f3c73 ethtool: add missing include necessary for CentOS5 11 years ago
Alexander Gozman 405baa3cb2 Fix compile-time error on old kernels and ethtool.h 11 years ago
sxhlinux 546ae9737b Update log-file.c
test whether tx_ud is NULL
11 years ago
Victor Julien 7ee2aa9c90 Add initial travis-ci integration. 11 years ago
Victor Julien 3beaa80aa2 Fix __thread configure check on Clang
AC_TRY_COMPILE puts the code in a function already, and Clang didn't like
the function within the function declaration. This lead to test failure.

Clang now properly detects __thread support.
11 years ago
Victor Julien a9282ed7f7 valgrind/magic: add suppression for known issue
Add suppression for Ubuntu 14.04 64bit.
11 years ago
Ken Steele f2e777e3a5 Fix lowercase table initialization (bug 1221)
The for loop needed to check for < 256, not < 255.
11 years ago
Victor Julien 1419e400a1 Update Changelog for 2.0.2 release 11 years ago
Victor Julien 1177d48920 lua: fix liblua use on OS X with macports
Set the correct lua pkg-config name used by macports.
11 years ago
Victor Julien 27eb0f450a defrag: fix timeout setting when config is missing
When the config is missing, DefragPolicyGetHostTimeout will default
to returning -1. This will effectively set no timeout at all, leading
to defrag trackers being freed too early.
11 years ago
Eric Leblond 97ca02f0c5 defrag: fix reconstruction
This patch is fixing an issue in defragmentation code. The
insertion of a fragment in the list of fragments is done with
respect to the offset of the fragment. But the code was using
the original offset of the fragment and not the one of the
new reconstructed fragment (which can be different in the
case of overlapping segment where the left part is trimmed).

This case could lead to some evasion techniques by causing
Suricata to analyse a different payload.
11 years ago
Eric Leblond 09fd7060ec unix socket: fix valgrind issue
This patch fixes the following issue reported by valgrind:
 31 errors in context 1 of 1:
 Conditional jump or move depends on uninitialised value(s)
    at 0x8AB2F8: UnixSocketPcapFilesCheck (runmode-unix-socket.c:279)
    by 0x97725D: UnixCommandBackgroundTasks (unix-manager.c:368)
    by 0x97BC52: UnixManagerThread (unix-manager.c:884)
    by 0x6155F6D: start_thread (pthread_create.c:311)
    by 0x6E3A9CC: clone (clone.S:113)

The running field in PcapCommand was not initialized.
11 years ago
Eric Leblond a33d1e28e9 unix-manager: fix crash when client disconnect
This patch fixes an issue in unix socket handling. It is possible
that a socket did disconnect when analysing a command and because
the data treatment is done in a loop on clients this was leading
to a update of the list of clients during the loop. So we need
in fact to use TAILQ_FOREACH_SAFE instead of TAILQ_FOREACH.

Reported-by: Luigi Sandon <luigi.sandon@gmail.com>
Fix-suggested-by: Luigi Sandon <luigi.sandon@gmail.com>
11 years ago
Ken Steele 6ebc20f6d8 Rework Tile CPU affinity setting to handle non-contiguous sets of CPUs.
It is possible to have a non-contiguous CPU set, which was not being
handled correctly on the TILE architecture.

Added a "rank" field in the ThreadVar to store the worker's rank separately
from the cpu for this case.
11 years ago