stream: update insert error checking

pull/9021/head
Victor Julien 2 years ago
parent 06419cecbc
commit db1cb2a032

@ -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 },
};

@ -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,

@ -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;
}

Loading…
Cancel
Save