suricata
|
#include "suricata-common.h"
#include "conf.h"
#include "defrag-hash.h"
#include "defrag-queue.h"
#include "defrag-config.h"
#include "util-random.h"
#include "util-byte.h"
#include "util-misc.h"
#include "util-hash-lookup3.h"
Go to the source code of this file.
Data Structures | |
struct | DefragHashKey4_ |
struct | DefragHashKey6_ |
Macros | |
#define | DefragTrackerIncrUsecnt(dt) SC_ATOMIC_ADD((dt)->use_cnt, 1) |
#define | DefragTrackerDecrUsecnt(dt) SC_ATOMIC_SUB((dt)->use_cnt, 1) |
#define | DEFRAG_DEFAULT_HASHSIZE 4096 |
#define | DEFRAG_DEFAULT_MEMCAP 16777216 |
#define | DEFRAG_DEFAULT_PREALLOC 1000 |
#define | CMP_DEFRAGTRACKER(d1, d2, id) |
Typedefs | |
typedef struct DefragHashKey4_ | DefragHashKey4 |
typedef struct DefragHashKey6_ | DefragHashKey6 |
Functions | |
int | DefragTrackerSetMemcap (uint64_t size) |
Update memcap value. More... | |
uint64_t | DefragTrackerGetMemcap (void) |
Return memcap value. More... | |
uint64_t | DefragTrackerGetMemuse (void) |
Return memuse value. More... | |
uint32_t | DefragTrackerSpareQueueGetSize (void) |
void | DefragTrackerMoveToSpare (DefragTracker *h) |
void | DefragTrackerRelease (DefragTracker *t) |
void | DefragTrackerClearMemory (DefragTracker *dt) |
void | DefragInitConfig (char quiet) |
initialize the configuration More... | |
void | DefragHashShutdown (void) |
shutdown the flow engine More... | |
DefragTracker * | DefragGetTrackerFromHash (Packet *p) |
DefragTracker * | DefragLookupTrackerFromHash (Packet *p) |
look up a tracker in the hash More... | |
#define CMP_DEFRAGTRACKER | ( | d1, | |
d2, | |||
id | |||
) |
Definition at line 443 of file defrag-hash.c.
#define DEFRAG_DEFAULT_HASHSIZE 4096 |
Definition at line 155 of file defrag-hash.c.
Referenced by DefragInitConfig().
#define DEFRAG_DEFAULT_MEMCAP 16777216 |
Definition at line 156 of file defrag-hash.c.
Referenced by DefragInitConfig().
#define DEFRAG_DEFAULT_PREALLOC 1000 |
Definition at line 157 of file defrag-hash.c.
Referenced by DefragInitConfig().
#define DefragTrackerDecrUsecnt | ( | dt | ) | SC_ATOMIC_SUB((dt)->use_cnt, 1) |
Definition at line 116 of file defrag-hash.c.
Referenced by DefragTrackerRelease().
#define DefragTrackerIncrUsecnt | ( | dt | ) | SC_ATOMIC_ADD((dt)->use_cnt, 1) |
Definition at line 114 of file defrag-hash.c.
Referenced by DefragGetTrackerFromHash(), and DefragLookupTrackerFromHash().
typedef struct DefragHashKey4_ DefragHashKey4 |
typedef struct DefragHashKey6_ DefragHashKey6 |
DefragTracker* DefragGetTrackerFromHash | ( | Packet * | p | ) |
Definition at line 526 of file defrag-hash.c.
References defragtracker_hash, DefragTrackerIncrUsecnt, DRLOCK_LOCK, DRLOCK_UNLOCK, DefragTrackerHashRow_::head, DefragTracker_::hnext, DefragTracker_::hprev, DefragTracker_::lock, DefragTracker_::remove, SCMutexLock, and DefragTrackerHashRow_::tail.
Referenced by DefragGetOsPolicy().
void DefragHashShutdown | ( | void | ) |
shutdown the flow engine
Definition at line 294 of file defrag-hash.c.
References BUG_ON, defrag_config, defragtracker_hash, DefragTrackerClearMemory(), DefragTrackerDequeue(), DefragTrackerQueueDestroy(), DRLOCK_DESTROY, DefragConfig_::hash_size, DefragTrackerHashRow_::head, DefragTracker_::hnext, SC_ATOMIC_DESTROY, SC_ATOMIC_GET, SC_ATOMIC_SUB, and SCFree.
Referenced by DefragDestroy().
void DefragInitConfig | ( | char | quiet | ) |
initialize the configuration
set config values for memcap, prealloc and hash_size
Definition at line 161 of file defrag-hash.c.
References ByteExtractStringUint32(), ConfGet(), ConfValIsTrue(), DEFRAG_CHECK_MEMCAP, defrag_config, DEFRAG_DEFAULT_HASHSIZE, DEFRAG_DEFAULT_MEMCAP, DEFRAG_DEFAULT_PREALLOC, defragtracker_hash, DefragTrackerEnqueue(), DefragTrackerQueueInit(), DRLOCK_INIT, FALSE, DefragConfig_::hash_rand, DefragConfig_::hash_size, DefragTrackerQueue_::len, ParseSizeStringU64(), DefragConfig_::prealloc, RandomGet(), SC_ATOMIC_ADD, SC_ATOMIC_GET, SC_ATOMIC_INIT, SC_ATOMIC_SET, SC_ERR_DEFRAG_INIT, SC_ERR_FATAL, SC_ERR_SIZE_PARSE, SCCalloc, SCLogDebug, SCLogError, unlikely, and WarnInvalidConfEntry.
Referenced by DefragInit().
DefragTracker* DefragLookupTrackerFromHash | ( | Packet * | p | ) |
look up a tracker in the hash
a | address to look up |
h | LOCKED tracker or NULL |
Definition at line 625 of file defrag-hash.c.
References defrag_config, defragtracker_hash, DefragTrackerClearMemory(), DefragTrackerIncrUsecnt, DRLOCK_LOCK, DRLOCK_TRYLOCK, DRLOCK_UNLOCK, DefragConfig_::hash_size, DefragTrackerHashRow_::head, DefragTracker_::hnext, DefragTracker_::hprev, DefragTracker_::lock, SC_ATOMIC_ADD, SC_ATOMIC_GET, SCMutexLock, SCMutexTrylock, SCMutexUnlock, and DefragTrackerHashRow_::tail.
void DefragTrackerClearMemory | ( | DefragTracker * | dt | ) |
Definition at line 149 of file defrag-hash.c.
References DefragTrackerFreeFrags(), and SC_ATOMIC_DESTROY.
Referenced by DefragHashShutdown(), DefragLookupTrackerFromHash(), and DefragTrackerMoveToSpare().
uint64_t DefragTrackerGetMemcap | ( | void | ) |
Return memcap value.
memcap | value |
Definition at line 53 of file defrag-hash.c.
References defrag_config, and SC_ATOMIC_GET.
Referenced by RunModeUnixSocketGetDefaultMode().
uint64_t DefragTrackerGetMemuse | ( | void | ) |
Return memuse value.
memuse | value |
Definition at line 64 of file defrag-hash.c.
References SC_ATOMIC_GET.
Referenced by RunModeUnixSocketGetDefaultMode().
void DefragTrackerMoveToSpare | ( | DefragTracker * | h | ) |
Definition at line 75 of file defrag-hash.c.
References DEFRAG_CHECK_MEMCAP, DefragTrackerClearMemory(), DefragTrackerEnqueue(), DefragTracker_::lock, SC_ATOMIC_ADD, SC_ATOMIC_INIT, SC_ATOMIC_SUB, SCFree, SCMalloc, SCMutexDestroy, SCMutexInit, and unlikely.
void DefragTrackerRelease | ( | DefragTracker * | t | ) |
Definition at line 143 of file defrag-hash.c.
References DefragTrackerDecrUsecnt, DefragTracker_::lock, and SCMutexUnlock.
Referenced by Defrag().
int DefragTrackerSetMemcap | ( | uint64_t | size | ) |
Update memcap value.
size | new memcap value |
Definition at line 38 of file defrag-hash.c.
References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.
Referenced by RunModeUnixSocketGetDefaultMode().
uint32_t DefragTrackerSpareQueueGetSize | ( | void | ) |
Definition at line 70 of file defrag-hash.c.
References DefragTrackerQueueLen().