packet handling: fix release function

Extended data were freed before the release function was called.
The result was that, in AF_PACKET IPS mode, the release function
was only sending void data because it the content of the extended
data is the content of the packet.

This patch updates the code to have the freeing of extended data
done in the cleaning function for a packet which is called by the
release function. This improves consistency of the code and fixes
the bug.
pull/943/head
Eric Leblond 11 years ago committed by Victor Julien
parent 3df904475c
commit 18c7eeefca

@ -82,6 +82,19 @@ int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
return TM_ECODE_OK;
}
static inline void PacketFreeExtData(Packet *p)
{
/* if p uses extended data, free them */
if (p->ext_pkt) {
if (!(p->flags & PKT_ZERO_COPY)) {
SCFree(p->ext_pkt);
}
p->ext_pkt = NULL;
}
}
/**
* \brief Return a malloced packet.
*/
@ -140,6 +153,7 @@ Packet *PacketGetFromAlloc(void)
*/
void PacketFreeOrRelease(Packet *p)
{
PacketFreeExtData(p);
if (p->flags & PKT_ALLOC)
PacketFree(p);
else

@ -273,14 +273,6 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
p->root = NULL;
}
/* if p uses extended data, free them */
if (p->ext_pkt) {
if (!(p->flags & PKT_ZERO_COPY)) {
SCFree(p->ext_pkt);
}
p->ext_pkt = NULL;
}
PACKET_PROFILING_END(p);
p->ReleasePacket(p);

Loading…
Cancel
Save