suricata
defrag-hash.c File Reference
#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"
Include dependency graph for defrag-hash.c:

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...
 
DefragTrackerDefragGetTrackerFromHash (Packet *p)
 
DefragTrackerDefragLookupTrackerFromHash (Packet *p)
 look up a tracker in the hash More...
 

Macro Definition Documentation

#define CMP_DEFRAGTRACKER (   d1,
  d2,
  id 
)
Value:
(((CMP_ADDR(&(d1)->src_addr, &(d2)->src) && \
CMP_ADDR(&(d1)->dst_addr, &(d2)->dst)) || \
(CMP_ADDR(&(d1)->src_addr, &(d2)->dst) && \
CMP_ADDR(&(d1)->dst_addr, &(d2)->src))) && \
(d1)->proto == IP_GET_IPPROTO(d2) && \
(d1)->id == (id) && \
(d1)->vlan_id[0] == (d2)->vlan_id[0] && \
(d1)->vlan_id[1] == (d2)->vlan_id[1])
uint16_t src
uint16_t dst
uint8_t proto
#define CMP_ADDR(a1, a2)
Definition: decode.h:240
#define IP_GET_IPPROTO(p)
Definition: decode.h:264

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 Documentation

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 dt)

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 h)
void DefragTrackerRelease ( DefragTracker t)

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: