packet pool: fix ext_pkt cleaning

The field ext_pkt was cleaned before calling the release function.
The result was that IPS mode such as the one of AF_PACKET were not
working anymore because they were not able to send the data which
were initially pointed by ext_pkt.

This patch moves the ext_pkt cleaning to the cleaning macro. This
ensures that the cleaning is done for allocated and pool packets.
pull/1105/merge
Eric Leblond 11 years ago committed by Victor Julien
parent 3ee504a3dc
commit 80adc40f68

@ -85,7 +85,7 @@ int DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
return TM_ECODE_OK; return TM_ECODE_OK;
} }
static inline void PacketFreeExtData(Packet *p) void PacketFreeExtData(Packet *p)
{ {
/* if p uses extended data, free them */ /* if p uses extended data, free them */
if (p->ext_pkt) { if (p->ext_pkt) {
@ -96,8 +96,6 @@ static inline void PacketFreeExtData(Packet *p)
} }
} }
/** /**
* \brief Return a malloced packet. * \brief Return a malloced packet.
*/ */
@ -156,7 +154,6 @@ Packet *PacketGetFromAlloc(void)
*/ */
void PacketFreeOrRelease(Packet *p) void PacketFreeOrRelease(Packet *p)
{ {
PacketFreeExtData(p);
if (p->flags & PKT_ALLOC) if (p->flags & PKT_ALLOC)
PacketFree(p); PacketFree(p);
else else

@ -623,6 +623,8 @@ typedef struct DecodeThreadVars_
(p)->level4_comp_csum = -1; \ (p)->level4_comp_csum = -1; \
} while (0) } while (0)
void PacketFreeExtData(Packet *p);
/** /**
* \brief Initialize a packet structure for use. * \brief Initialize a packet structure for use.
*/ */
@ -662,6 +664,7 @@ typedef struct DecodeThreadVars_
(p)->dp = 0; \ (p)->dp = 0; \
(p)->proto = 0; \ (p)->proto = 0; \
(p)->recursion_level = 0; \ (p)->recursion_level = 0; \
PacketFreeExtData(p); \
(p)->flags = (p)->flags & PKT_ALLOC; \ (p)->flags = (p)->flags & PKT_ALLOC; \
(p)->flowflags = 0; \ (p)->flowflags = 0; \
(p)->pkt_src = 0; \ (p)->pkt_src = 0; \
@ -733,6 +736,7 @@ typedef struct DecodeThreadVars_
if ((p)->pktvar != NULL) { \ if ((p)->pktvar != NULL) { \
PktVarFree((p)->pktvar); \ PktVarFree((p)->pktvar); \
} \ } \
PacketFreeExtData(p); \
SCMutexDestroy(&(p)->tunnel_mutex); \ SCMutexDestroy(&(p)->tunnel_mutex); \
AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \ AppLayerDecoderEventsFreeEvents(&(p)->app_layer_events); \
PACKET_PROFILING_RESET((p)); \ PACKET_PROFILING_RESET((p)); \

@ -396,25 +396,11 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
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", p->root->flags & PKT_ALLOC ? "true" : "false");
FlowDeReference(&p->root->flow); FlowDeReference(&p->root->flow);
/* if p->root uses extended data, free them */
if (p->root->ext_pkt) {
if (!(p->root->flags & PKT_ZERO_COPY)) {
SCFree(p->root->ext_pkt);
}
p->root->ext_pkt = NULL;
}
p->root->ReleasePacket(p->root); p->root->ReleasePacket(p->root);
p->root = NULL; 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); PACKET_PROFILING_END(p);
p->ReleasePacket(p); p->ReleasePacket(p);

Loading…
Cancel
Save