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

Go to the source code of this file.

Data Structures

struct  Host_
 
struct  HostHashRow_
 
struct  HostConfig_
 

Macros

#define HRLOCK_MUTEX
 
#define HRLOCK_TYPE   SCMutex
 
#define HRLOCK_INIT(fb)   SCMutexInit(&(fb)->lock, NULL)
 
#define HRLOCK_DESTROY(fb)   SCMutexDestroy(&(fb)->lock)
 
#define HRLOCK_LOCK(fb)   SCMutexLock(&(fb)->lock)
 
#define HRLOCK_TRYLOCK(fb)   SCMutexTrylock(&(fb)->lock)
 
#define HRLOCK_UNLOCK(fb)   SCMutexUnlock(&(fb)->lock)
 
#define HOST_VERBOSE   0
 
#define HOST_QUIET   1
 
#define HOST_CHECK_MEMCAP(size)   ((((uint64_t)SC_ATOMIC_GET(host_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(host_config.memcap)))
 check if a memory alloc would fit in the memcap More...
 
#define HostIncrUsecnt(h)   (void)SC_ATOMIC_ADD((h)->use_cnt, 1)
 
#define HostDecrUsecnt(h)   (void)SC_ATOMIC_SUB((h)->use_cnt, 1)
 
#define HostReference(dst_h_ptr, h)
 
#define HostDeReference(src_h_ptr)
 

Typedefs

typedef struct Host_ Host
 
typedef struct HostConfig_ HostConfig
 

Functions

struct HostHashRow_ __attribute__ ((aligned(CLS))) HostHashRow
 
 SC_ATOMIC_EXTERN (uint64_t, host_memuse)
 
 SC_ATOMIC_EXTERN (uint32_t, host_counter)
 
 SC_ATOMIC_EXTERN (uint32_t, host_prune_idx)
 
void HostInitConfig (bool quiet)
 initialize the configuration More...
 
void HostShutdown (void)
 shutdown the flow engine More...
 
void HostCleanup (void)
 Cleanup the host engine. More...
 
HostHostLookupHostFromHash (Address *)
 look up a host in the hash More...
 
HostHostGetHostFromHash (Address *)
 
void HostRelease (Host *)
 
void HostLock (Host *)
 
void HostClearMemory (Host *)
 
void HostMoveToSpare (Host *)
 
void HostPrintStats (void)
 print some host stats More...
 
void HostRegisterUnittests (void)
 
HostHostAlloc (void)
 
void HostFree (Host *)
 
void HostUnlock (Host *h)
 
int HostSetMemcap (uint64_t)
 Update memcap value. More...
 
uint64_t HostGetMemcap (void)
 Return memcap value. More...
 
uint64_t HostGetMemuse (void)
 Return memuse value. More...
 

Variables

HRLOCK_TYPE lock
 
Hosthead
 
Hosttail
 
HostHashRow * host_hash
 
HostConfig host_config
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file host.h.

Macro Definition Documentation

◆ HOST_CHECK_MEMCAP

#define HOST_CHECK_MEMCAP (   size)    ((((uint64_t)SC_ATOMIC_GET(host_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(host_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 110 of file host.h.

◆ HOST_QUIET

#define HOST_QUIET   1

Definition at line 94 of file host.h.

◆ HOST_VERBOSE

#define HOST_VERBOSE   0

Definition at line 93 of file host.h.

◆ HostDecrUsecnt

#define HostDecrUsecnt (   h)    (void)SC_ATOMIC_SUB((h)->use_cnt, 1)

Definition at line 115 of file host.h.

◆ HostDeReference

#define HostDeReference (   src_h_ptr)
Value:
do { \
if (*(src_h_ptr) != NULL) { \
HostDecrUsecnt(*(src_h_ptr)); \
*(src_h_ptr) = NULL; \
} \
} while (0)

Definition at line 125 of file host.h.

◆ HostIncrUsecnt

#define HostIncrUsecnt (   h)    (void)SC_ATOMIC_ADD((h)->use_cnt, 1)

Definition at line 113 of file host.h.

◆ HostReference

#define HostReference (   dst_h_ptr,
 
)
Value:
do { \
if ((h) != NULL) { \
HostIncrUsecnt((h)); \
*(dst_h_ptr) = h; \
} \
} while (0)

Definition at line 118 of file host.h.

◆ HRLOCK_DESTROY

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

Definition at line 51 of file host.h.

◆ HRLOCK_INIT

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

Definition at line 50 of file host.h.

◆ HRLOCK_LOCK

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

Definition at line 52 of file host.h.

◆ HRLOCK_MUTEX

#define HRLOCK_MUTEX

Spinlocks or Mutex for the flow buckets.

Definition at line 33 of file host.h.

◆ HRLOCK_TRYLOCK

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

Definition at line 53 of file host.h.

◆ HRLOCK_TYPE

#define HRLOCK_TYPE   SCMutex

Definition at line 49 of file host.h.

◆ HRLOCK_UNLOCK

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

Definition at line 54 of file host.h.

Typedef Documentation

◆ Host

typedef struct Host_ Host

◆ HostConfig

typedef struct HostConfig_ HostConfig

Function Documentation

◆ __attribute__()

struct HostHashRow_ __attribute__ ( (aligned(CLS))  )

◆ HostAlloc()

Host* HostAlloc ( void  )

Definition at line 106 of file host.c.

References HOST_CHECK_MEMCAP.

◆ HostCleanup()

void HostCleanup ( void  )

Cleanup the host engine.

Cleanup the host engine from tag and threshold.

Definition at line 332 of file host.c.

References HostConfig_::hash_size, Host_::hnext, host_config, host_hash, HostClearMemory(), HostFreeStorage(), HostMoveToSpare(), Host_::hprev, HRLOCK_LOCK, HRLOCK_UNLOCK, Host_::iprep, and SC_ATOMIC_GET.

Here is the call graph for this function:

◆ HostClearMemory()

void HostClearMemory ( Host )

Definition at line 150 of file host.c.

References BUG_ON, HostFreeStorage(), HostStorageSize(), Host_::iprep, SC_ATOMIC_GET, and SRepFreeHostData().

Referenced by HostCleanup(), and HostFree().

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

◆ HostFree()

void HostFree ( Host )

Definition at line 125 of file host.c.

References HostClearMemory(), Host_::m, SC_ATOMIC_SUB, SCFree, and SCMutexDestroy.

Here is the call graph for this function:

◆ HostGetHostFromHash()

Host* HostGetHostFromHash ( Address )

Definition at line 486 of file host.c.

Referenced by TagHashAddTag().

Here is the caller graph for this function:

◆ HostGetMemcap()

uint64_t HostGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 83 of file host.c.

References host_config, and SC_ATOMIC_GET.

Referenced by AppLayerRegisterGlobalCounters().

Here is the caller graph for this function:

◆ HostGetMemuse()

uint64_t HostGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 94 of file host.c.

References SC_ATOMIC_GET.

Referenced by AppLayerRegisterGlobalCounters().

Here is the caller graph for this function:

◆ HostInitConfig()

void HostInitConfig ( bool  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

Definition at line 168 of file host.c.

References DEBUG_VALIDATE_BUG_ON, HostStorageSize(), and SCLogDebug.

Here is the call graph for this function:

◆ HostLock()

void HostLock ( Host )

Definition at line 467 of file host.c.

References Host_::m, and SCMutexLock.

◆ HostLookupHostFromHash()

Host* HostLookupHostFromHash ( Address a)

look up a host in the hash

Parameters
aaddress to look up
Return values
hLOCKED host or NULL

Definition at line 585 of file host.c.

◆ HostMoveToSpare()

void HostMoveToSpare ( Host )

Definition at line 100 of file host.c.

References HostEnqueue().

Referenced by HostCleanup().

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

◆ HostPrintStats()

void HostPrintStats ( void  )

print some host stats

Warning
Not thread safe

Definition at line 284 of file host.c.

References host_config, SC_ATOMIC_GET, and SCLogPerf.

Referenced by HostShutdown().

Here is the caller graph for this function:

◆ HostRegisterUnittests()

void HostRegisterUnittests ( void  )

Definition at line 717 of file host.c.

References RegisterHostStorageTests().

Here is the call graph for this function:

◆ HostRelease()

void HostRelease ( Host )

Definition at line 461 of file host.c.

References HostDecrUsecnt, Host_::m, and SCMutexUnlock.

◆ HostSetMemcap()

int HostSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 68 of file host.c.

References host_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ HostShutdown()

void HostShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

Definition at line 296 of file host.c.

References HostDequeue(), and HostPrintStats().

Referenced by GlobalsDestroy().

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

◆ HostUnlock()

void HostUnlock ( Host h)

Definition at line 472 of file host.c.

References Host_::m, and SCMutexUnlock.

◆ SC_ATOMIC_EXTERN() [1/3]

SC_ATOMIC_EXTERN ( uint32_t  ,
host_counter   
)

◆ SC_ATOMIC_EXTERN() [2/3]

SC_ATOMIC_EXTERN ( uint32_t  ,
host_prune_idx   
)

◆ SC_ATOMIC_EXTERN() [3/3]

SC_ATOMIC_EXTERN ( uint64_t  ,
host_memuse   
)

Variable Documentation

◆ head

Host* head

Definition at line 1 of file host.h.

◆ host_config

HostConfig host_config

Definition at line 53 of file host.c.

Referenced by HostCleanup(), HostGetMemcap(), HostPrintStats(), HostSetMemcap(), and HostTimeoutHash().

◆ host_hash

HostHashRow* host_hash

host hash table

Definition at line 50 of file host.c.

Referenced by HostCleanup(), and HostTimeoutHash().

◆ lock

Definition at line 0 of file host.h.

◆ tail

Host* tail

Definition at line 2 of file host.h.