Go to the documentation of this file.
39 #define MAX_PENDING_RETURN_PACKETS 32
44 static inline PktPool *GetThreadPacketPool(
void)
60 static int PacketPoolIsEmpty(
PktPool *pool)
71 PktPool *my_pool = GetThreadPacketPool();
73 if (PacketPoolIsEmpty(my_pool)) {
80 while(PacketPoolIsEmpty(my_pool))
100 PktPool *my_pool = GetThreadPacketPool();
108 pp = p = my_pool->
head;
144 static void PacketPoolStorePacket(
Packet *p)
146 p->
pool = GetThreadPacketPool();
151 static void PacketPoolGetReturnedPackets(
PktPool *pool)
169 PktPool *pool = GetThreadPacketPool();
170 #ifdef DEBUG_VALIDATION
171 BUG_ON(pool->initialized == 0);
172 BUG_ON(pool->destroyed == 1);
185 PacketPoolGetReturnedPackets(pool);
209 PktPool *my_pool = GetThreadPacketPool();
218 #ifdef DEBUG_VALIDATION
219 BUG_ON(pool->initialized == 0);
220 BUG_ON(pool->destroyed == 1);
221 BUG_ON(my_pool->initialized == 0);
222 BUG_ON(my_pool->destroyed == 1);
225 if (pool == my_pool) {
231 if (pending_pool == NULL) {
238 }
else if (pending_pool == pool) {
271 PktPool *my_pool = GetThreadPacketPool();
273 #ifdef DEBUG_VALIDATION
274 BUG_ON(my_pool->initialized);
275 my_pool->initialized = 1;
276 my_pool->destroyed = 0;
288 PktPool *my_pool = GetThreadPacketPool();
290 #ifdef DEBUG_VALIDATION
291 BUG_ON(my_pool->initialized);
292 my_pool->initialized = 1;
293 my_pool->destroyed = 0;
301 SCLogDebug(
"preallocating packets... packet size %" PRIuMAX
"",
307 FatalError(
"Fatal error encountered while allocating a packet. Exiting...");
309 PacketPoolStorePacket(p);
319 PktPool *my_pool = GetThreadPacketPool();
321 #ifdef DEBUG_VALIDATION
322 BUG_ON(my_pool && my_pool->destroyed);
333 #ifdef DEBUG_VALIDATION
345 #ifdef DEBUG_VALIDATION
346 my_pool->initialized = 0;
347 my_pool->destroyed = 1;
364 SCLogDebug(
"Packet %p is a tunnel packet: %s",
365 p,p->
root ?
"upper layer" :
"tunnel root");
376 SCLogDebug(
"root pkt: outstanding %u", outstanding);
377 if (outstanding == 0) {
378 SCLogDebug(
"no tunnel packets outstanding, no more tunnel "
379 "packet(s) depending on this root");
385 SCLogDebug(
"tunnel root Packet %p: outstanding > 0, so "
386 "packets are still depending on this root, setting "
387 "SET_TUNNEL_PKT_VERDICTED", p);
399 SCLogDebug(
"NOT IS_TUNNEL_ROOT_PKT, so tunnel pkt");
403 SCLogDebug(
"tunnel pkt: outstanding %u", outstanding);
407 if (outstanding == 0 &&
410 SCLogDebug(
"root verdicted == true && no outstanding");
413 SCLogDebug(
"setting proot = 1 for root pkt, p->root %p "
414 "(tunnel packet %p)", p->
root, p);
423 SCLogDebug(
"NOT IS_TUNNEL_PKT_VERDICTED (%s) || "
424 "outstanding > 0 (%u)",
433 SCLogDebug(
"tunnel stuff done, move on (proot %d)", proot);
490 #define RESERVED_PACKETS 10
511 "must be at least %d",
518 uint32_t packets = (pending_packets / threads) - 1;
519 if (packets < max_pending_return_packets)
520 max_pending_return_packets = packets;
526 SCLogDebug(
"detect threads %u, max packets %u, max_pending_return_packets %u",
527 threads, packets, max_pending_return_packets);
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
struct Packet_::@40 persistent
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
#define TM_FLAG_DETECT_TM
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
void(* OutHandler)(ThreadVars *, Packet *)
void PacketReleaseRefs(Packet *p)
#define IS_TUNNEL_ROOT_PKT(p)
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
returns a count of all the threads that match the flag
void PacketPoolPostRunmodes(void)
Set the max_pending_return_packets value.
#define MAX_PENDING_RETURN_PACKETS
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
thread_local PktPool thread_pkt_pool
void TmqhReleasePacketsToPacketPool(PacketQueue *pq)
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed,...
void PacketPoolInit(void)
Packet *(* InHandler)(ThreadVars *)
#define TUNNEL_PKT_TPR(p)
void PacketReinit(Packet *p)
Recycle a packet structure for reuse.
#define SCMutexUnlock(mut)
void CaptureStatsUpdate(ThreadVars *tv, const Packet *p)
#define IS_TUNNEL_PKT_VERDICTED(p)
void PacketPoolWaitForN(int n)
Wait until we have the requested amount of packets in the pool.
Per thread variable structure.
void PacketFree(Packet *p)
Return a malloced packet.
Packet * TmqhInputPacketpool(ThreadVars *tv)
void PacketPoolWait(void)
uint16_t max_pending_packets
#define SET_TUNNEL_PKT_VERDICTED(p)
#define SCMutexInit(mut, mutattrs)
PktPoolLockedStack return_stack
void TmqhPacketpoolRegister(void)
TmqhPacketpoolRegister \initonly.
void(* ReleasePacket)(struct Packet_ *)
Tmqh tmqh_table[TMQH_SIZE]
#define SC_ATOMIC_RESET(name)
wrapper for reinitializing an atomic variable.
Packet * PacketDequeue(PacketQueue *q)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
#define TUNNEL_PKT_RTV(p)
#define TUNNEL_INCR_PKT_RTV_NOLOCK(p)
#define PACKET_PROFILING_END(p)
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
void PacketPoolInitEmpty(void)
struct PktPool_ * pending_pool
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
void PacketPoolDestroy(void)
#define DEBUG_VALIDATE_BUG_ON(exp)