From: Victor Julien Date: Tue, 22 Mar 2022 16:01:03 +0000 (+0100) Subject: stream/segtree: simplify error handling X-Git-Tag: suricata-7.0.0-beta1~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13554f7e443abcff4f8ea82f5988fbebd933b0c2;p=thirdparty%2Fsuricata.git stream/segtree: simplify error handling Now that spurious retransmissions don't propegate into the reassembly code, error handling can be simplified. --- diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 708a9cb490..87b5efe713 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -163,19 +163,10 @@ static inline bool CheckOverlap(struct TCPSEG *tree, TcpSegment *seg) * \retval 2 not inserted, data overlap * \retval 1 inserted with overlap detected * \retval 0 inserted, no overlap - * \retval -1 error */ static int DoInsertSegment (TcpStream *stream, TcpSegment *seg, TcpSegment **dup_seg, Packet *p) { - /* before our base_seq we don't insert it in our list */ - if (SEQ_LEQ(SEG_SEQ_RIGHT_EDGE(seg), stream->base_seq)) - { - SCLogDebug("not inserting: SEQ+payload %"PRIu32", last_ack %"PRIu32", " - "base_seq %"PRIu32, (seg->seq + TCP_SEG_LEN(seg)), - stream->last_ack, stream->base_seq); - StreamTcpSetEvent(p, STREAM_REASSEMBLY_SEGMENT_BEFORE_BASE_SEQ); - return -1; - } + BUG_ON(SEQ_LEQ(SEG_SEQ_RIGHT_EDGE(seg), stream->base_seq)); /* fast track */ if (RB_EMPTY(&stream->seg_tree)) { @@ -645,12 +636,7 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ /* insert segment into list. Note: doesn't handle the data */ int r = DoInsertSegment (stream, seg, &dup_seg, p); - SCLogDebug("DoInsertSegment returned %d", r); - if (r < 0) { - StatsIncr(tv, ra_ctx->counter_tcp_reass_list_fail); - StreamTcpSegmentReturntoPool(seg); - SCReturnInt(-1); - } + if (IsTcpSessionDumpingEnabled()) { StreamTcpSegmentAddPacketData(seg, p, tv, ra_ctx); }