suricata
|
#include "flow.h"
Go to the source code of this file.
Data Structures | |
struct | FlowBucket_ |
Macros | |
#define | FBLOCK_MUTEX |
#define | FBLOCK_INIT(fb) SCMutexInit(&(fb)->m, NULL) |
#define | FBLOCK_DESTROY(fb) SCMutexDestroy(&(fb)->m) |
#define | FBLOCK_LOCK(fb) SCMutexLock(&(fb)->m) |
#define | FBLOCK_TRYLOCK(fb) SCMutexTrylock(&(fb)->m) |
#define | FBLOCK_UNLOCK(fb) SCMutexUnlock(&(fb)->m) |
Functions | |
struct FlowBucket_ | __attribute__ ((aligned(CLS))) FlowBucket |
SC_ATOMIC_DECLARE (uint32_t, next_ts) | |
Flow * | FlowGetFlowFromHash (ThreadVars *tv, FlowLookupStruct *tctx, Packet *, Flow **) |
Get Flow for packet. More... | |
Flow * | FlowGetFromFlowKey (FlowKey *key, struct timespec *ttime, const uint32_t hash) |
Get or create a Flow using a FlowKey. More... | |
Flow * | FlowGetExistingFlowFromFlowId (int64_t flow_id) |
Look for existing Flow using a flow id value. More... | |
uint32_t | FlowKeyGetHash (FlowKey *flow_key) |
uint32_t | FlowGetIpPairProtoHash (const Packet *p) |
Variables | |
Flow * | head |
Flow * | evicted |
SCMutex | m |
Definition in file flow-hash.h.
#define FBLOCK_DESTROY | ( | fb | ) | SCMutexDestroy(&(fb)->m) |
Definition at line 73 of file flow-hash.h.
#define FBLOCK_INIT | ( | fb | ) | SCMutexInit(&(fb)->m, NULL) |
Definition at line 72 of file flow-hash.h.
#define FBLOCK_LOCK | ( | fb | ) | SCMutexLock(&(fb)->m) |
Definition at line 74 of file flow-hash.h.
#define FBLOCK_MUTEX |
Spinlocks or Mutex for the flow buckets.
Definition at line 32 of file flow-hash.h.
#define FBLOCK_TRYLOCK | ( | fb | ) | SCMutexTrylock(&(fb)->m) |
Definition at line 75 of file flow-hash.h.
#define FBLOCK_UNLOCK | ( | fb | ) | SCMutexUnlock(&(fb)->m) |
Definition at line 76 of file flow-hash.h.
struct FlowBucket_ __attribute__ | ( | (aligned(CLS)) | ) |
Flow* FlowGetExistingFlowFromFlowId | ( | int64_t | flow_id | ) |
Look for existing Flow using a flow id value.
Hash retrieval function for flows. Looks up the hash bucket containing the flow pointer. Then compares the flow_id with the found flow's flow_id to see if it is the flow we need.
flow_id | Flow ID of the flow to look for |
f | LOCKED flow or NULL |
Definition at line 992 of file flow-hash.c.
References FBLOCK_LOCK, flow_config, flow_hash, FlowCnf_::hash_size, Flow_::next, and SCLogDebug.
Flow* FlowGetFlowFromHash | ( | ThreadVars * | tv, |
FlowLookupStruct * | fls, | ||
Packet * | p, | ||
Flow ** | dest | ||
) |
Get Flow for packet.
Hash retrieval function for flows. Looks up the hash bucket containing the flow pointer. Then compares the packet with the found flow to see if it is the flow we need. If it isn't, walk the list until the right flow is found.
If the flow is not found or the bucket was empty, a new flow is taken from the spare pool. The pool will alloc new flows as long as we stay within our memcap limit.
The p->flow pointer is updated to point to the flow.
tv | thread vars |
dtv | decode thread vars (for flow log api thread data) |
f | LOCKED flow or NULL |
Definition at line 867 of file flow-hash.c.
References FBLOCK_LOCK, flow_config, flow_hash, Packet_::flow_hash, FlowCnf_::hash_size, and SCLogDebug.
Referenced by FlowHandlePacket().
Get or create a Flow using a FlowKey.
Hash retrieval function for flows. Looks up the hash bucket containing the flow pointer. Then compares the packet with the found flow to see if it is the flow we need. If it isn't, walk the list until the right flow is found. Return a new Flow if ever no Flow was found.
key | Pointer to FlowKey build using flow to look for |
ttime | time to use for flow creation |
hash | Value of the flow hash |
f | LOCKED flow or NULL |
Definition at line 1056 of file flow-hash.c.
uint32_t FlowGetIpPairProtoHash | ( | const Packet * | p | ) |
Definition at line 117 of file flow-hash.c.
uint32_t FlowKeyGetHash | ( | FlowKey * | fk | ) |
Basic hashing function for FlowKey
Definition at line 308 of file flow-hash.c.
References Address_::address, Address_::address_un_data32, FlowHashKey4_::addrs, ARRAY_SIZE, FlowKey_::dp, FlowKey_::dst, Address_::family, flow_config, g_livedev_mask, g_vlan_mask, FlowCnf_::hash_rand, hashword(), FlowHashKey4_::livedev, FlowKey_::livedev_id, FlowHashKey6_::pad, FlowHashKey4_::ports, FlowHashKey4_::proto, FlowKey_::proto, FlowHashKey4_::recur, FlowKey_::recursion_level, FlowKey_::sp, FlowKey_::src, FlowHashKey4_::u32, FlowHashKey4_::vlan_id, and FlowKey_::vlan_id.
__attribute__::SC_ATOMIC_DECLARE | ( | uint32_t | , |
next_ts | |||
) |
timestamp in seconds of the earliest possible moment a flow will time out in this row. Set by the flow manager. Cleared to 0 by workers, either when new flows are added or when a flow state changes. The flow manager sets this to UINT_MAX for empty buckets.
Flow* evicted |
head of the list of evicted flows for this row. Waiting to be collected by the Flow Manager.
Definition at line 4 of file flow-hash.h.
Flow* head |
head of the list of active flows for this row.
Definition at line 1 of file flow-hash.h.
Referenced by AppLayerProtoDetectPPRegister(), DetectPortCleanupList(), DetectPortInsert(), DetectPortPrintList(), SBB_RB_FIND_INCLUSIVE(), SCLogAppendOPIfaceCtx(), and StatsReleaseCounters().
SCMutex m |
Definition at line 6 of file flow-hash.h.
Referenced by BoyerMoore(), BoyerMooreNocase(), DetectFileHashMatch(), TmThreadCreateCmdThreadByName(), and TmThreadCreateMgmtThreadByName().