suricata
defrag-hash.h File Reference
#include "decode.h"
#include "defrag.h"
#include "util-exception-policy.h"
#include "util-exception-policy-types.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_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 (bool quiet)
 initialize the configuration More...
 
void DefragHashShutdown (void)
 shutdown the flow engine More...
 
DefragTrackerDefragLookupTrackerFromHash (Packet *)
 look up a tracker in the hash More...
 
DefragTrackerDefragGetTrackerFromHash (ThreadVars *tv, DecodeThreadVars *dtv, Packet *)
 
void DefragTrackerRelease (DefragTracker *)
 
void DefragTrackerClearMemory (DefragTracker *)
 
void DefragTrackerMoveToSpare (DefragTracker *)
 
int DefragTrackerSetMemcap (uint64_t)
 Update memcap value. More...
 
uint64_t DefragTrackerGetMemcap (void)
 Return memcap value. More...
 
uint64_t DefragTrackerGetMemuse (void)
 Return memuse value. More...
 
enum ExceptionPolicy DefragGetMemcapExceptionPolicy (void)
 

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

◆ DRLOCK_DESTROY

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

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

◆ DRLOCK_INIT

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

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

◆ DRLOCK_LOCK

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

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

◆ DRLOCK_MUTEX

#define DRLOCK_MUTEX

Spinlocks or Mutex for the flow buckets.

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

◆ DRLOCK_TRYLOCK

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

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

◆ DRLOCK_TYPE

#define DRLOCK_TYPE   SCMutex

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

◆ DRLOCK_UNLOCK

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

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

Typedef Documentation

◆ DefragConfig

typedef struct DefragConfig_ DefragConfig

◆ DefragTrackerHashRow

Function Documentation

◆ DefragGetMemcapExceptionPolicy()

enum ExceptionPolicy DefragGetMemcapExceptionPolicy ( void  )

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

◆ DefragGetTrackerFromHash()

DefragTracker* DefragGetTrackerFromHash ( ThreadVars tv,
DecodeThreadVars dtv,
Packet  
)

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

◆ DefragHashShutdown()

void DefragHashShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

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

References DefragTrackerDequeue().

Referenced by DefragDestroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefragInitConfig()

void DefragInitConfig ( bool  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

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

References defrag_config, DefragTrackerStackInit(), 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 624 of file defrag-hash.c.

◆ DefragTrackerClearMemory()

void DefragTrackerClearMemory ( DefragTracker )

Definition at line 158 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 63 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 74 of file defrag-hash.c.

References SC_ATOMIC_GET.

◆ DefragTrackerMoveToSpare()

void DefragTrackerMoveToSpare ( DefragTracker )

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

References DefragTrackerEnqueue().

Here is the call graph for this function:

◆ DefragTrackerRelease()

void DefragTrackerRelease ( DefragTracker )

Definition at line 152 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 48 of file defrag-hash.c.

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ 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

◆ defragtracker_hash

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

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

Referenced by DefragTimeoutHash().