suricata
defrag-hash.h File Reference
#include "decode.h"
#include "defrag.h"
Include dependency graph for defrag-hash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DefragTrackerHashRow_
 
struct  DefragConfig_
 

Macros

#define DRLOCK_MUTEX
 
#define DRLOCK_TYPE   SCMutex
 
#define DRLOCK_INIT(fb)   SCMutexInit(&(fb)->lock, NULL)
 
#define DRLOCK_DESTROY(fb)   SCMutexDestroy(&(fb)->lock)
 
#define DRLOCK_LOCK(fb)   SCMutexLock(&(fb)->lock)
 
#define DRLOCK_TRYLOCK(fb)   SCMutexTrylock(&(fb)->lock)
 
#define DRLOCK_UNLOCK(fb)   SCMutexUnlock(&(fb)->lock)
 
#define DEFRAG_VERBOSE   0
 
#define DEFRAG_QUIET   1
 
#define DEFRAG_CHECK_MEMCAP(size)   ((((uint64_t)SC_ATOMIC_GET(defrag_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(defrag_config.memcap)))
 check if a memory alloc would fit in the memcap More...
 

Typedefs

typedef struct DefragTrackerHashRow_ DefragTrackerHashRow
 
typedef struct DefragConfig_ DefragConfig
 

Functions

 SC_ATOMIC_DECLARE (uint64_t, defrag_memuse)
 
 SC_ATOMIC_DECLARE (unsigned int, defragtracker_counter)
 
 SC_ATOMIC_DECLARE (unsigned int, defragtracker_prune_idx)
 
void DefragInitConfig (char quiet)
 initialize the configuration More...
 
void DefragHashShutdown (void)
 shutdown the flow engine More...
 
DefragTrackerDefragLookupTrackerFromHash (Packet *)
 look up a tracker in the hash More...
 
DefragTrackerDefragGetTrackerFromHash (Packet *)
 
void DefragTrackerRelease (DefragTracker *)
 
void DefragTrackerClearMemory (DefragTracker *)
 
void DefragTrackerMoveToSpare (DefragTracker *)
 
uint32_t DefragTrackerSpareQueueGetSize (void)
 
int DefragTrackerSetMemcap (uint64_t)
 Update memcap value. More...
 
uint64_t DefragTrackerGetMemcap (void)
 Return memcap value. More...
 
uint64_t DefragTrackerGetMemuse (void)
 Return memuse value. More...
 

Variables

DefragTrackerHashRowdefragtracker_hash
 
DefragConfig defrag_config
 

Detailed Description

Macro Definition Documentation

#define DEFRAG_CHECK_MEMCAP (   size)    ((((uint64_t)SC_ATOMIC_GET(defrag_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(defrag_config.memcap)))

check if a memory alloc would fit in the memcap

Parameters
sizememory allocation size to check
Return values
1it fits
0no fit

Definition at line 84 of file defrag-hash.h.

Referenced by DefragInitConfig(), and DefragTrackerMoveToSpare().

#define DEFRAG_QUIET   1

Definition at line 68 of file defrag-hash.h.

#define DEFRAG_VERBOSE   0

Definition at line 67 of file defrag-hash.h.

#define DRLOCK_DESTROY (   fb)    SCMutexDestroy(&(fb)->lock)

Definition at line 50 of file defrag-hash.h.

Referenced by DefragHashShutdown().

#define DRLOCK_INIT (   fb)    SCMutexInit(&(fb)->lock, NULL)

Definition at line 49 of file defrag-hash.h.

Referenced by DefragInitConfig().

#define DRLOCK_LOCK (   fb)    SCMutexLock(&(fb)->lock)

Definition at line 51 of file defrag-hash.h.

Referenced by DefragGetTrackerFromHash(), and DefragLookupTrackerFromHash().

#define DRLOCK_MUTEX

Spinlocks or Mutex for the flow buckets.

Definition at line 32 of file defrag-hash.h.

#define DRLOCK_TRYLOCK (   fb)    SCMutexTrylock(&(fb)->lock)

Definition at line 52 of file defrag-hash.h.

Referenced by DefragLookupTrackerFromHash(), and DefragTimeoutHash().

#define DRLOCK_TYPE   SCMutex

Definition at line 48 of file defrag-hash.h.

#define DRLOCK_UNLOCK (   fb)    SCMutexUnlock(&(fb)->lock)

Typedef Documentation

typedef struct DefragConfig_ DefragConfig

Function Documentation

void DefragHashShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

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().

Here is the call graph for this function:

Here is the caller graph for this function:

DefragTracker* DefragLookupTrackerFromHash ( Packet p)
void DefragTrackerClearMemory ( DefragTracker )

Definition at line 149 of file defrag-hash.c.

References DefragTrackerFreeFrags(), and SC_ATOMIC_DESTROY.

Referenced by DefragHashShutdown(), DefragLookupTrackerFromHash(), and DefragTrackerMoveToSpare().

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t DefragTrackerGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 53 of file defrag-hash.c.

References defrag_config, and SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

uint64_t DefragTrackerGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 64 of file defrag-hash.c.

References SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void DefragTrackerMoveToSpare ( DefragTracker )
void DefragTrackerRelease ( DefragTracker )

Definition at line 143 of file defrag-hash.c.

References DefragTrackerDecrUsecnt, DefragTracker_::lock, and SCMutexUnlock.

Referenced by Defrag().

Here is the caller graph for this function:

int DefragTrackerSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 38 of file defrag-hash.c.

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

uint32_t DefragTrackerSpareQueueGetSize ( void  )

Definition at line 70 of file defrag-hash.c.

References DefragTrackerQueueLen().

Here is the call graph for this function:

SC_ATOMIC_DECLARE ( uint64_t  ,
defrag_memuse   
)
SC_ATOMIC_DECLARE ( unsigned  int,
defragtracker_counter   
)
SC_ATOMIC_DECLARE ( unsigned  int,
defragtracker_prune_idx   
)

Variable Documentation

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

Definition at line 65 of file defrag-hash.h.

Referenced by DefragGetTrackerFromHash(), DefragHashShutdown(), DefragInitConfig(), DefragLookupTrackerFromHash(), and DefragTimeoutHash().