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_EXTERN (uint64_t, defrag_memuse)
 
 SC_ATOMIC_EXTERN (unsigned int, defragtracker_counter)
 
 SC_ATOMIC_EXTERN (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

◆ DEFRAG_CHECK_MEMCAP

#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 85 of file defrag-hash.h.

◆ DEFRAG_QUIET

#define DEFRAG_QUIET   1

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

◆ DEFRAG_VERBOSE

#define DEFRAG_VERBOSE   0

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

◆ DRLOCK_DESTROY

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

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

◆ DRLOCK_INIT

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

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

◆ DRLOCK_LOCK

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

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

◆ DRLOCK_MUTEX

#define DRLOCK_MUTEX

Spinlocks or Mutex for the flow buckets.

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

◆ DRLOCK_TRYLOCK

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

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

◆ DRLOCK_TYPE

#define DRLOCK_TYPE   SCMutex

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

◆ DRLOCK_UNLOCK

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

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

Typedef Documentation

◆ DefragConfig

typedef struct DefragConfig_ DefragConfig

◆ DefragTrackerHashRow

Function Documentation

◆ DefragGetTrackerFromHash()

DefragTracker* DefragGetTrackerFromHash ( Packet )

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

◆ DefragHashShutdown()

void DefragHashShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

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

Referenced by DefragDestroy().

Here is the caller graph for this function:

◆ DefragInitConfig()

void DefragInitConfig ( char  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

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

References defrag_config, DefragTrackerQueueInit(), SC_ATOMIC_INIT, and SCLogDebug.

Here is the call graph for this function:

◆ DefragLookupTrackerFromHash()

DefragTracker* DefragLookupTrackerFromHash ( Packet p)

look up a tracker in the hash

Parameters
aaddress to look up
Return values
hLOCKED tracker or NULL

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

◆ DefragTrackerClearMemory()

void DefragTrackerClearMemory ( DefragTracker )

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

References DefragTrackerFreeFrags().

Here is the call graph for this function:

◆ DefragTrackerGetMemcap()

uint64_t DefragTrackerGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

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

References defrag_config, and SC_ATOMIC_GET.

◆ DefragTrackerGetMemuse()

uint64_t DefragTrackerGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

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

References SC_ATOMIC_GET.

◆ DefragTrackerMoveToSpare()

void DefragTrackerMoveToSpare ( DefragTracker )

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

References DefragTrackerEnqueue().

Here is the call graph for this function:

◆ DefragTrackerRelease()

void DefragTrackerRelease ( DefragTracker )

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

References DefragTrackerDecrUsecnt, DefragTracker_::lock, and SCMutexUnlock.

◆ DefragTrackerSetMemcap()

int DefragTrackerSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

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

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ DefragTrackerSpareQueueGetSize()

uint32_t DefragTrackerSpareQueueGetSize ( void  )

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

References DefragTrackerQueueLen().

Here is the call graph for this function:

◆ SC_ATOMIC_EXTERN() [1/3]

SC_ATOMIC_EXTERN ( uint64_t  ,
defrag_memuse   
)

◆ SC_ATOMIC_EXTERN() [2/3]

SC_ATOMIC_EXTERN ( unsigned int  ,
defragtracker_counter   
)

◆ SC_ATOMIC_EXTERN() [3/3]

SC_ATOMIC_EXTERN ( unsigned int  ,
defragtracker_prune_idx   
)

Variable Documentation

◆ defrag_config

DefragConfig defrag_config

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

Referenced by DefragInitConfig(), DefragTrackerGetMemcap(), and DefragTrackerSetMemcap().

◆ defragtracker_hash

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

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