diff --git a/src/decode-events.c b/src/decode-events.c index 22242e7049..207de286f6 100644 --- a/src/decode-events.c +++ b/src/decode-events.c @@ -856,6 +856,18 @@ const struct DecodeEvents_ DEvents[] = { "stream.reassembly_depth_reached", STREAM_REASSEMBLY_DEPTH_REACHED, }, + { + "stream.reassembly_insert_memcap", + STREAM_REASSEMBLY_INSERT_MEMCAP, + }, + { + "stream.reassembly_insert_limit", + STREAM_REASSEMBLY_INSERT_LIMIT, + }, + { + "stream.reassembly_insert_invalid", + STREAM_REASSEMBLY_INSERT_INVALID, + }, { NULL, 0 }, }; diff --git a/src/decode-events.h b/src/decode-events.h index 6e2d638c3c..451482403c 100644 --- a/src/decode-events.h +++ b/src/decode-events.h @@ -292,6 +292,9 @@ enum { STREAM_REASSEMBLY_SEQ_GAP, STREAM_REASSEMBLY_OVERLAP_DIFFERENT_DATA, STREAM_REASSEMBLY_DEPTH_REACHED, + STREAM_REASSEMBLY_INSERT_MEMCAP, + STREAM_REASSEMBLY_INSERT_LIMIT, + STREAM_REASSEMBLY_INSERT_INVALID, /* should always be last! */ DECODE_EVENT_MAX, diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 4013bd57f9..164825440f 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -98,11 +98,8 @@ static inline int InsertSegmentDataCustom(TcpStream *stream, TcpSegment *seg, ui int ret = StreamingBufferInsertAt(&stream->sb, &stream_config.sbcnf, &seg->sbseg, data + data_offset, data_len - data_offset, stream_offset); - if (ret != 0) { - /* StreamingBufferInsertAt can return -2 only if the offset is wrong, which should be - * impossible in this path. */ - DEBUG_VALIDATE_BUG_ON(ret != -1); - SCReturnInt(SC_ENOMEM); + if (ret != SC_OK) { + SCReturnInt(ret); } #ifdef DEBUG { @@ -550,6 +547,13 @@ static int DoHandleData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, if (res != SC_OK) { if (res == SC_ENOMEM) { StatsIncr(tv, ra_ctx->counter_tcp_segment_memcap); + StreamTcpSetEvent(p, STREAM_REASSEMBLY_INSERT_MEMCAP); + } else if (res == SC_ELIMIT) { + StreamTcpSetEvent(p, STREAM_REASSEMBLY_INSERT_LIMIT); + } else if (res == SC_EINVAL) { + StreamTcpSetEvent(p, STREAM_REASSEMBLY_INSERT_INVALID); + } else { + DEBUG_VALIDATE_BUG_ON(1); } return -1; }