suricata
|
#include "suricata-common.h"
#include "tmqh-packetpool.h"
#include "tm-queuehandlers.h"
#include "tm-threads.h"
#include "threads.h"
#include "decode.h"
#include "tm-modules.h"
#include "packet.h"
#include "util-profiling.h"
#include "util-validate.h"
#include "action-globals.h"
Go to the source code of this file.
Macros | |
#define | MAX_PENDING_RETURN_PACKETS 32 |
#define | RESERVED_PACKETS 10 |
Functions | |
void | TmqhPacketpoolRegister (void) |
TmqhPacketpoolRegister \initonly. More... | |
void | PacketPoolWait (void) |
Packet * | PacketPoolGetPacket (void) |
Get a new packet from the packet pool. More... | |
void | PacketPoolReturnPacket (Packet *p) |
Return packet to Packet pool. More... | |
void | PacketPoolInitEmpty (void) |
void | PacketPoolInit (void) |
void | PacketPoolDestroy (void) |
Packet * | TmqhInputPacketpool (ThreadVars *tv) |
void | TmqhOutputPacketpool (ThreadVars *t, Packet *p) |
void | TmqhReleasePacketsToPacketPool (PacketQueue *pq) |
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed, and wants to return the packets back to the packetpool. More... | |
void | PacketPoolPostRunmodes (void) |
Set the max_pending_return_packets value. More... | |
Variables | |
uint16_t | max_pending_packets |
thread_local PktPool | thread_pkt_pool |
Packetpool queue handlers. Packet pool is implemented as a stack.
Definition in file tmqh-packetpool.c.
#define MAX_PENDING_RETURN_PACKETS 32 |
Definition at line 42 of file tmqh-packetpool.c.
#define RESERVED_PACKETS 10 |
number of packets to keep reserved when calculating the pending return packets count. This assumes we need at max 10 packets in one PacketPoolWaitForN call. The actual number is 9 now, so this has a bit of margin.
Definition at line 468 of file tmqh-packetpool.c.
void PacketPoolDestroy | ( | void | ) |
Definition at line 293 of file tmqh-packetpool.c.
Packet* PacketPoolGetPacket | ( | void | ) |
Get a new packet from the packet pool.
Only allocates from the thread's local stack, or mallocs new packets. If the local stack is empty, first move all the return stack packets to the local stack.
Packet | pointer, or NULL on failure. |
Definition at line 127 of file tmqh-packetpool.c.
Referenced by FlowForceReassemblyPseudoPacketGet(), PacketGetFromQueueOrAlloc(), and TmqhInputPacketpool().
void PacketPoolInit | ( | void | ) |
Definition at line 262 of file tmqh-packetpool.c.
Referenced by PostRunDeinit().
void PacketPoolInitEmpty | ( | void | ) |
Definition at line 246 of file tmqh-packetpool.c.
void PacketPoolPostRunmodes | ( | void | ) |
Set the max_pending_return_packets value.
Set it to the max pending packets value, divided by the number of lister threads. Normally, in autofp these are the stream/detect/log worker threads.
The max_pending_return_packets value needs to stay below the packet pool size of the 'producers' (normally pkt capture threads but also flow timeout injection ) to avoid a deadlock where all the 'workers' keep packets in their return pools, while the capture thread can't continue because its pool is empty.
Definition at line 482 of file tmqh-packetpool.c.
References FatalError, max_pending_packets, RESERVED_PACKETS, TM_FLAG_DETECT_TM, and TmThreadCountThreadsByTmmFlags().
void PacketPoolReturnPacket | ( | Packet * | p | ) |
Return packet to Packet pool.
Definition at line 179 of file tmqh-packetpool.c.
Referenced by PacketFreeOrRelease(), and PacketGetFromQueueOrAlloc().
void PacketPoolWait | ( | void | ) |
Definition at line 80 of file tmqh-packetpool.c.
Referenced by FlowForceReassemblyPseudoPacketGet(), ReceiveErfFileLoop(), and ReceivePfringLoop().
Packet* TmqhInputPacketpool | ( | ThreadVars * | tv | ) |
Definition at line 328 of file tmqh-packetpool.c.
References PacketPoolGetPacket().
Referenced by TmqhPacketpoolRegister().
void TmqhOutputPacketpool | ( | ThreadVars * | t, |
Packet * | p | ||
) |
Definition at line 333 of file tmqh-packetpool.c.
References Packet_::action, ACTION_DROP, BOOL2STR, CaptureStatsUpdate(), IS_TUNNEL_PKT, IS_TUNNEL_PKT_VERDICTED, IS_TUNNEL_ROOT_PKT, lock, PACKET_PROFILING_END, PacketReleaseRefs(), Packet_::persistent, Packet_::pool, Packet_::ReleasePacket, Packet_::root, SCEnter, SCLogDebug, SCReturn, SCSpinlock, SCSpinLock, SCSpinUnlock, SET_TUNNEL_PKT_VERDICTED, TUNNEL_INCR_PKT_RTV_NOLOCK, Packet_::tunnel_lock, TUNNEL_PKT_RTV, and TUNNEL_PKT_TPR.
Referenced by TmqhPacketpoolRegister(), and TmqhReleasePacketsToPacketPool().
void TmqhPacketpoolRegister | ( | void | ) |
TmqhPacketpoolRegister \initonly.
Definition at line 55 of file tmqh-packetpool.c.
References Tmqh_::InHandler, Tmqh_::name, Tmqh_::OutHandler, TMQH_PACKETPOOL, tmqh_table, TmqhInputPacketpool(), and TmqhOutputPacketpool().
Referenced by TmqhSetup().
void TmqhReleasePacketsToPacketPool | ( | PacketQueue * | pq | ) |
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed, and wants to return the packets back to the packetpool.
pq | Pointer to the packetqueue from which the packets have to be returned back to the packetpool |
Definition at line 448 of file tmqh-packetpool.c.
References DEBUG_VALIDATE_BUG_ON, Packet_::flow, PacketDequeue(), and TmqhOutputPacketpool().
thread_local PktPool thread_pkt_pool |
Definition at line 44 of file tmqh-packetpool.c.