From: Victor Julien Date: Wed, 8 Mar 2017 11:50:32 +0000 (+0100) Subject: stream: add insert failure counters X-Git-Tag: suricata-4.0.0-beta1~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8924653cd4cc1f1f8aa51d7ecf1d0f702d83c1b8;p=thirdparty%2Fsuricata.git stream: add insert failure counters --- diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index e3327763ac..95f3dbc16f 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -538,13 +538,18 @@ static int DoHandleData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, TcpSegment *seg, Packet *p, uint32_t pkt_seq, uint8_t *pkt_data, uint16_t pkt_datalen) { - /* insert segment into list. Note: doesn't handle the data */ #ifdef DEBUG SCLogDebug("pre insert"); PrintList(stream->seg_list); #endif + /* insert segment into list. Note: doesn't handle the data */ int r = DoInsertSegment (stream, seg, p); + if (r < 0) { + StatsIncr(tv, ra_ctx->counter_tcp_reass_list_fail); + StreamTcpSegmentReturntoPool(seg); + SCReturnInt(-1); + } #ifdef DEBUG SCLogDebug("post insert"); @@ -555,6 +560,7 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ /* no overlap, straight data insert */ int res = InsertSegmentDataCustom(stream, seg, pkt_data, pkt_datalen); if (res < 0) { + StatsIncr(tv, ra_ctx->counter_tcp_reass_data_normal_fail); StreamTcpRemoveSegmentFromStream(stream, seg); StreamTcpSegmentReturntoPool(seg); SCReturnInt(-1); @@ -567,14 +573,11 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ /* now let's consider the data in the overlap case */ int res = DoHandleData(tv, ra_ctx, stream, seg, p); if (res < 0) { + StatsIncr(tv, ra_ctx->counter_tcp_reass_data_overlap_fail); StreamTcpRemoveSegmentFromStream(stream, seg); StreamTcpSegmentReturntoPool(seg); SCReturnInt(-1); } - - } else if (r < 0) { - StreamTcpSegmentReturntoPool(seg); - SCReturnInt(-1); } SCReturnInt(0); diff --git a/src/stream-tcp-reassemble.h b/src/stream-tcp-reassemble.h index 3162ca7132..9471e4d04e 100644 --- a/src/stream-tcp-reassemble.h +++ b/src/stream-tcp-reassemble.h @@ -64,6 +64,10 @@ typedef struct TcpReassemblyThreadCtx_ { uint16_t counter_tcp_reass_overlap; /** count overlaps with different data */ uint16_t counter_tcp_reass_overlap_diff_data; + + uint16_t counter_tcp_reass_data_normal_fail; + uint16_t counter_tcp_reass_data_overlap_fail; + uint16_t counter_tcp_reass_list_fail; } TcpReassemblyThreadCtx; #define OS_POLICY_DEFAULT OS_POLICY_BSD diff --git a/src/stream-tcp.c b/src/stream-tcp.c index b77975cd4d..e0ce65073e 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -4957,6 +4957,11 @@ TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data) stt->ra_ctx->counter_tcp_reass_overlap = StatsRegisterCounter("tcp.overlap", tv); stt->ra_ctx->counter_tcp_reass_overlap_diff_data = StatsRegisterCounter("tcp.overlap_diff_data", tv); + stt->ra_ctx->counter_tcp_reass_data_normal_fail = StatsRegisterCounter("tcp.insert_data_normal_fail", tv); + stt->ra_ctx->counter_tcp_reass_data_overlap_fail = StatsRegisterCounter("tcp.insert_data_overlap_fail", tv); + stt->ra_ctx->counter_tcp_reass_list_fail = StatsRegisterCounter("tcp.insert_list_fail", tv); + + SCLogDebug("StreamTcp thread specific ctx online at %p, reassembly ctx %p", stt, stt->ra_ctx);