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_


#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...


typedef struct DefragTrackerHashRow_ DefragTrackerHashRow
typedef struct DefragConfig_ DefragConfig


 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)


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

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

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


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

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


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

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


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

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



Spinlocks or Mutex for the flow buckets.

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


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

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


#define DRLOCK_TYPE   SCMutex

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


#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 72 of file defrag-hash.c.

◆ DefragGetTrackerFromHash()

DefragTracker* DefragGetTrackerFromHash ( ThreadVars tv,
DecodeThreadVars dtv,

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

◆ DefragHashShutdown()

void DefragHashShutdown ( void  )

shutdown the flow engine

Not thread safe

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

Referenced by DefragDestroy().

Here is the caller graph for this function:

◆ DefragInitConfig()

void DefragInitConfig ( bool  quiet)

initialize the configuration

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

aaddress to look up
Return values
hLOCKED tracker or NULL

Definition at line 649 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

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

References defrag_config, and SC_ATOMIC_GET.

◆ DefragTrackerGetMemuse()

uint64_t DefragTrackerGetMemuse ( void  )

Return memuse value.

Return values

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

References SC_ATOMIC_GET.

◆ DefragTrackerMoveToSpare()

void DefragTrackerMoveToSpare ( DefragTracker )

Definition at line 83 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.

sizenew memcap value

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

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.


SC_ATOMIC_EXTERN ( uint64_t  ,


SC_ATOMIC_EXTERN ( unsigned int  ,


SC_ATOMIC_EXTERN ( unsigned int  ,

Variable Documentation

◆ defrag_config

◆ defragtracker_hash

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

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

Referenced by DefragTimeoutHash().