packetpool: remove PKT_ALLOC flag

Use Packet::pool instead. If Packet::pool is non-NULL the packet is
owned by a pool. Otherwise it is allocated and should be freed after
use.
pull/8085/head
Victor Julien 4 years ago
parent 3ed7b4473e
commit 68a9da52ad

@ -179,7 +179,6 @@ Packet *PacketGetFromAlloc(void)
memset(p, 0, SIZE_OF_PACKET);
PacketInit(p);
p->ReleasePacket = PacketFree;
p->flags |= PKT_ALLOC;
SCLogDebug("allocated a new packet only using alloc...");
@ -192,11 +191,11 @@ Packet *PacketGetFromAlloc(void)
*/
void PacketFreeOrRelease(Packet *p)
{
if (p->flags & PKT_ALLOC)
PacketFree(p);
else {
if (likely(p->pool != NULL)) {
p->ReleasePacket = PacketPoolReturnPacket;
PacketPoolReturnPacket(p);
} else {
PacketFree(p);
}
}

@ -978,8 +978,8 @@ void DecodeUnregisterCounters(void);
/** Flag to indicate that packet contents should not be inspected */
#define PKT_NOPAYLOAD_INSPECTION BIT_U32(2)
/** Packet was alloc'd this run, needs to be freed */
#define PKT_ALLOC BIT_U32(3)
// vacancy
/** Packet has matched a tag */
#define PKT_HAS_TAG BIT_U32(4)
/** Packet payload was added to reassembled stream */

@ -95,7 +95,7 @@ void PacketReinit(Packet *p)
p->proto = 0;
p->recursion_level = 0;
PACKET_FREE_EXTDATA(p);
p->flags = p->flags & PKT_ALLOC;
p->flags = 0;
p->flowflags = 0;
p->pkt_src = 0;
p->vlan_id[0] = 0;

@ -142,9 +142,6 @@ void PacketPoolWaitForN(int n)
*/
static void PacketPoolStorePacket(Packet *p)
{
/* Clear the PKT_ALLOC flag, since that indicates to push back
* onto the ring buffer. */
p->flags &= ~PKT_ALLOC;
p->pool = GetThreadPacketPool();
p->ReleasePacket = PacketPoolReturnPacket;
PacketPoolReturnPacket(p);
@ -361,7 +358,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
bool proot = false;
SCEnter();
SCLogDebug("Packet %p, p->root %p, alloced %s", p, p->root, p->flags & PKT_ALLOC ? "true" : "false");
SCLogDebug("Packet %p, p->root %p, alloced %s", p, p->root, BOOL2STR(p->pool == NULL));
if (IS_TUNNEL_PKT(p)) {
SCLogDebug("Packet %p is a tunnel packet: %s",
@ -441,7 +438,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
/* we're done with the tunnel root now as well */
if (proot == true) {
SCLogDebug("getting rid of root pkt... alloc'd %s", p->root->flags & PKT_ALLOC ? "true" : "false");
SCLogDebug("getting rid of root pkt... alloc'd %s", BOOL2STR(p->root->pool == NULL));
PacketReleaseRefs(p->root);
p->root->ReleasePacket(p->root);

@ -82,7 +82,7 @@ void TmqhInputSimpleShutdownHandler(ThreadVars *tv)
void TmqhOutputSimple(ThreadVars *t, Packet *p)
{
SCLogDebug("Packet %p, p->root %p, alloced %s", p, p->root, p->flags & PKT_ALLOC ? "true":"false");
SCLogDebug("Packet %p, p->root %p, alloced %s", p, p->root, BOOL2STR(p->pool == NULL));
PacketQueue *q = t->outq->pq;

Loading…
Cancel
Save