Fix packet flags field not being cleared properly when the packet is being reused. Add some debug statements and cleanup some.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent e2376948dd
commit a8116f65c8

@ -353,6 +353,8 @@ int AppLayerHandleMsg(StreamMsg *smsg, char need_lock)
r = AppLayerParse(smsg->flow, alproto, smsg->flags, r = AppLayerParse(smsg->flow, alproto, smsg->flags,
smsg->data.data, smsg->data.data_len, need_lock); smsg->data.data, smsg->data.data_len, need_lock);
} else {
SCLogDebug("ALPROTO_UNKNOWN flow %p", smsg->flow);
} }
} else { } else {
SCLogDebug("stream data (len %" PRIu32 " (%" PRIu32 ")), alproto " SCLogDebug("stream data (len %" PRIu32 " (%" PRIu32 ")), alproto "

@ -27,7 +27,9 @@ void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt
* \param p Packet to set the flag in * \param p Packet to set the flag in
*/ */
inline void DecodeSetNoPayloadInspectionFlag(Packet *p) { inline void DecodeSetNoPayloadInspectionFlag(Packet *p) {
SCEnter();
p->flags |= PKT_NOPAYLOAD_INSPECTION; p->flags |= PKT_NOPAYLOAD_INSPECTION;
SCReturn;
} }
/** \brief Set the No packet inspection Flag for the packet. /** \brief Set the No packet inspection Flag for the packet.
@ -35,7 +37,9 @@ inline void DecodeSetNoPayloadInspectionFlag(Packet *p) {
* \param p Packet to set the flag in * \param p Packet to set the flag in
*/ */
inline void DecodeSetNoPacketInspectionFlag(Packet *p) { inline void DecodeSetNoPacketInspectionFlag(Packet *p) {
SCEnter();
p->flags |= PKT_NOPACKET_INSPECTION; p->flags |= PKT_NOPACKET_INSPECTION;
SCReturn;
} }
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv) void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)

@ -352,6 +352,7 @@ typedef struct DecodeThreadVars_
(p)->dp = 0; \ (p)->dp = 0; \
(p)->flow = NULL; \ (p)->flow = NULL; \
(p)->flowflags = 0; \ (p)->flowflags = 0; \
(p)->flags = 0; \
(p)->alerts.cnt = 0; \ (p)->alerts.cnt = 0; \
PktHttpUriFree((p)); \ PktHttpUriFree((p)); \
if ((p)->pktvar != NULL) { \ if ((p)->pktvar != NULL) { \

@ -76,7 +76,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
FlowBucket *fb = &flow_hash[key]; FlowBucket *fb = &flow_hash[key];
SCMutexLock(&fb->m); SCMutexLock(&fb->m);
SCLogDebug("FlowGetFlowFromHash: fb %p fb->f %p", fb, fb->f); SCLogDebug("fb %p fb->f %p", fb, fb->f);
/* see if the bucket already has a flow */ /* see if the bucket already has a flow */
if (fb->f == NULL) { if (fb->f == NULL) {

@ -366,10 +366,14 @@ void FlowHandlePacket (ThreadVars *tv, Packet *p)
p->flowflags |= FLOW_PKT_TOSERVER_IPONLY_SET; p->flowflags |= FLOW_PKT_TOSERVER_IPONLY_SET;
/*set the detection bypass flags*/ /*set the detection bypass flags*/
if (f->flags & FLOW_NOPACKET_INSPECTION) if (f->flags & FLOW_NOPACKET_INSPECTION) {
SCLogDebug("setting FLOW_NOPACKET_INSPECTION flag on flow %p", f);
DecodeSetNoPacketInspectionFlag(p); DecodeSetNoPacketInspectionFlag(p);
if (f->flags & FLOW_NOPAYLOAD_INSPECTION) }
if (f->flags & FLOW_NOPAYLOAD_INSPECTION) {
SCLogDebug("setting FLOW_NOPAYLOAD_INSPECTION flag on flow %p", f);
DecodeSetNoPayloadInspectionFlag(p); DecodeSetNoPayloadInspectionFlag(p);
}
/* set the flow in the packet */ /* set the flow in the packet */
p->flow = f; p->flow = f;
@ -785,9 +789,14 @@ int FlowSetProtoEmergencyTimeout(uint8_t proto, uint32_t emerg_new_timeout, uint
* \param f Flow to set the flag in * \param f Flow to set the flag in
*/ */
void FlowLockSetNoPacketInspectionFlag(Flow *f) { void FlowLockSetNoPacketInspectionFlag(Flow *f) {
SCEnter();
SCLogDebug("flow %p", f);
SCMutexLock(&f->m); SCMutexLock(&f->m);
f->flags |= FLOW_NOPACKET_INSPECTION; f->flags |= FLOW_NOPACKET_INSPECTION;
SCMutexUnlock(&f->m); SCMutexUnlock(&f->m);
SCReturn;
} }
/** \brief Set the No Packet Inspection Flag without locking the flow. /** \brief Set the No Packet Inspection Flag without locking the flow.
@ -795,7 +804,12 @@ void FlowLockSetNoPacketInspectionFlag(Flow *f) {
* \param f Flow to set the flag in * \param f Flow to set the flag in
*/ */
void FlowSetNoPacketInspectionFlag(Flow *f) { void FlowSetNoPacketInspectionFlag(Flow *f) {
SCEnter();
SCLogDebug("flow %p", f);
f->flags |= FLOW_NOPACKET_INSPECTION; f->flags |= FLOW_NOPACKET_INSPECTION;
SCReturn;
} }
/** \brief Set the No payload inspection Flag after locking the flow. /** \brief Set the No payload inspection Flag after locking the flow.
@ -803,9 +817,14 @@ void FlowSetNoPacketInspectionFlag(Flow *f) {
* \param f Flow to set the flag in * \param f Flow to set the flag in
*/ */
void FlowLockSetNoPayloadInspectionFlag(Flow *f) { void FlowLockSetNoPayloadInspectionFlag(Flow *f) {
SCEnter();
SCLogDebug("flow %p", f);
SCMutexLock(&f->m); SCMutexLock(&f->m);
f->flags |= FLOW_NOPAYLOAD_INSPECTION; f->flags |= FLOW_NOPAYLOAD_INSPECTION;
SCMutexUnlock(&f->m); SCMutexUnlock(&f->m);
SCReturn;
} }
/** \brief Set the No payload inspection Flag without locking the flow. /** \brief Set the No payload inspection Flag without locking the flow.
@ -813,7 +832,12 @@ void FlowLockSetNoPayloadInspectionFlag(Flow *f) {
* \param f Flow to set the flag in * \param f Flow to set the flag in
*/ */
void FlowSetNoPayloadInspectionFlag(Flow *f) { void FlowSetNoPayloadInspectionFlag(Flow *f) {
SCEnter();
SCLogDebug("flow %p", f);
f->flags |= FLOW_NOPAYLOAD_INSPECTION; f->flags |= FLOW_NOPAYLOAD_INSPECTION;
SCReturn;
} }
#ifdef UNITTESTS #ifdef UNITTESTS

@ -1468,7 +1468,7 @@ int StreamTcpReassembleHandleSegment(TcpReassemblyThreadCtx *ra_ctx,
Packet *p) Packet *p)
{ {
SCEnter(); SCEnter();
SCLogDebug("ssn %p, stream %p, p %p, p->payload_len %"PRIu16"\n", SCLogDebug("ssn %p, stream %p, p %p, p->payload_len %"PRIu16"",
ssn, stream, p, p->payload_len); ssn, stream, p, p->payload_len);
/* handle ack received */ /* handle ack received */

Loading…
Cancel
Save