From: Victor Julien Date: Tue, 17 Dec 2013 15:33:26 +0000 (+0100) Subject: stream: remove flow reference from StreamMsg X-Git-Tag: suricata-2.0rc1~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b159c1714c615911b76bf4a6589594487e6cba02;p=thirdparty%2Fsuricata.git stream: remove flow reference from StreamMsg StreamMsg' flow reference was used mostly to make sure a flow would not get removed from the hash before inspection. For this it needed to reference the flow use_cnt reference counter. Nowadays we have more advanced flow timeout handling. This will make sure that if there still are pending smsgs' in a flow, these will still be processed. --- diff --git a/src/app-layer.c b/src/app-layer.c index 490df796dc..e88f966581 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -375,7 +375,6 @@ int AppLayerHandleTCPMsg(StreamMsg *smsg, TcpSession *ssn) printf("=> Stream Data -- end\n"); #endif SCLogDebug("smsg %p", smsg); - BUG_ON(smsg->flow == NULL); if (ssn != NULL) { SCLogDebug("storing smsg %p in the tcp session", smsg); @@ -415,14 +414,11 @@ int AppLayerHandleTCPMsg(StreamMsg *smsg, TcpSession *ssn) } } - FlowDeReference(&smsg->flow); } else { /* no ssn ptr */ /* if there is no ssn ptr we won't * be inspecting this msg in detect * so return it to the pool. */ - FlowDeReference(&smsg->flow); - /* return the used message to the queue */ StreamMsgReturnToPool(smsg); } diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index b942281f6a..28e0b31fb5 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -1751,8 +1751,6 @@ static void StreamTcpSetupMsg(TcpSession *ssn, TcpStream *stream, Packet *p, } smsg->data_len = 0; - FlowReference(&smsg->flow, p->flow); - BUG_ON(smsg->flow == NULL); SCLogDebug("smsg %p", smsg); SCReturn; @@ -3403,15 +3401,13 @@ int StreamTcpReassembleProcessAppLayer(TcpReassemblyThreadCtx *ra_ctx, TcpSessio do { smsg = StreamMsgGetFromQueue(ra_ctx->stream_q); if (smsg != NULL) { - SCLogDebug("smsg %p, next %p, prev %p, flow %p, q->len %u, " + SCLogDebug("smsg %p, next %p, prev %p, q->len %u, " "smsg->datalen %u, direction %s%s", - smsg, smsg->next, smsg->prev, smsg->flow, + smsg, smsg->next, smsg->prev, ra_ctx->stream_q->len, smsg->data_len, smsg->flags & STREAM_TOSERVER ? "toserver":"", smsg->flags & STREAM_TOCLIENT ? "toclient":""); - BUG_ON(smsg->flow == NULL); - //PrintRawDataFp(stderr, smsg->data, smsg->data_len); /* Handle the stream msg. No need to use locking, flow is diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 03d61c1d32..26eb59cc10 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -196,7 +196,6 @@ void StreamTcpSessionClear(void *ssnptr) SCLogDebug("returning smsg %p to pool", smsg); smsg->next = NULL; smsg->prev = NULL; - FlowDeReference(&smsg->flow); StreamMsgReturnToPool(smsg); smsg = smsg_next; } @@ -208,7 +207,6 @@ void StreamTcpSessionClear(void *ssnptr) SCLogDebug("returning smsg %p to pool", smsg); smsg->next = NULL; smsg->prev = NULL; - FlowDeReference(&smsg->flow); StreamMsgReturnToPool(smsg); smsg = smsg_next; } @@ -306,7 +304,6 @@ void StreamTcpSessionPoolCleanup(void *s) SCLogDebug("returning smsg %p to pool", smsg); smsg->next = NULL; smsg->prev = NULL; - FlowDeReference(&smsg->flow); StreamMsgReturnToPool(smsg); smsg = smsg_next; } @@ -318,7 +315,6 @@ void StreamTcpSessionPoolCleanup(void *s) SCLogDebug("returning smsg %p to pool", smsg); smsg->next = NULL; smsg->prev = NULL; - FlowDeReference(&smsg->flow); StreamMsgReturnToPool(smsg); smsg = smsg_next; } diff --git a/src/stream.c b/src/stream.c index 4c9354ae1c..3acda3a085 100644 --- a/src/stream.c +++ b/src/stream.c @@ -216,7 +216,6 @@ void StreamMsgReturnListToPool(void *list) { SCLogDebug("returning smsg %p to pool", smsg); smsg->next = NULL; smsg->prev = NULL; - FlowDeReference(&smsg->flow); StreamMsgReturnToPool(smsg); smsg = smsg_next; } diff --git a/src/stream.h b/src/stream.h index 764170c03c..4d4ccbaa59 100644 --- a/src/stream.h +++ b/src/stream.h @@ -38,7 +38,6 @@ typedef struct StreamMsg_ { uint8_t flags; /**< msg flags */ - Flow *flow; /**< parent flow */ struct StreamMsg_ *next; struct StreamMsg_ *prev;