]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
stream: remove GAP flag from stream
authorVictor Julien <victor@inliniac.net>
Wed, 23 Sep 2020 11:52:29 +0000 (13:52 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 25 Sep 2020 05:24:54 +0000 (07:24 +0200)
This flag was checked in many places, but never set expect in 2 unittests.

src/app-layer.c
src/flow.c
src/output-json-flow.c
src/stream-tcp-list.c
src/stream-tcp-private.h
src/stream-tcp-reassemble.c
src/stream-tcp.c

index 001acf2d7de289ec6f14f409ce4aff9ed7ec401f..60f2a278c14b866be9fbda5a63d4ca7d044ab640 100644 (file)
@@ -209,12 +209,8 @@ static void TCPProtoDetectCheckBailConditions(ThreadVars *tv,
         STREAM_RIGHT_EDGE(&ssn->server) : 0;
     SCLogDebug("size_ts %"PRIu64", size_tc %"PRIu64, size_ts, size_tc);
 
-#ifdef DEBUG_VALIDATION
-    if (!(ssn->client.flags & STREAMTCP_STREAM_FLAG_GAP))
-        BUG_ON(size_ts > 1000000UL);
-    if (!(ssn->server.flags & STREAMTCP_STREAM_FLAG_GAP))
-        BUG_ON(size_tc > 1000000UL);
-#endif /* DEBUG_VALIDATION */
+    DEBUG_VALIDATE_BUG_ON(size_ts > 1000000UL);
+    DEBUG_VALIDATE_BUG_ON(size_tc > 1000000UL);
 
     if (ProtoDetectDone(f, ssn, STREAM_TOSERVER) &&
         ProtoDetectDone(f, ssn, STREAM_TOCLIENT))
index 14b32f4cc264292cf1ac284ed6b2a550447f72fa..614540dd534a1796fc6f518e774c4ebb6625c3af 100644 (file)
@@ -1127,9 +1127,6 @@ uint8_t FlowGetDisruptionFlags(const Flow *f, uint8_t flags)
     if (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) {
         newflags |= STREAM_DEPTH;
     }
-    if (stream->flags & STREAMTCP_STREAM_FLAG_GAP) {
-        newflags |= STREAM_GAP;
-    }
     /* todo: handle pass case (also for UDP!) */
 
     return newflags;
index 9f7fd413004a1642bfa7d30a4be648217ab1dca4..1a0b823334e54f2a0cd5aba55db23b9e98b6e325 100644 (file)
@@ -315,10 +315,6 @@ static void EveFlowLogJSON(JsonFlowLogThread *aft, JsonBuilder *jb, Flow *f)
             const char *tcp_state = StreamTcpStateAsString(ssn->state);
             if (tcp_state != NULL)
                 jb_set_string(jb, "state", tcp_state);
-            if (ssn->client.flags & STREAMTCP_STREAM_FLAG_GAP)
-                JB_SET_TRUE(jb, "gap_ts");
-            if (ssn->server.flags & STREAMTCP_STREAM_FLAG_GAP)
-                JB_SET_TRUE(jb, "gap_tc");
         }
 
         /* Close tcp. */
index cb47ee8e9237ea9850cfc72a9beda0911982bba4..518e95897701e328fa49f3d51c2ec6a73ebff6d0 100644 (file)
@@ -636,7 +636,7 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_
 static inline bool SegmentInUse(const TcpStream *stream, const TcpSegment *seg)
 {
     /* if proto detect isn't done, we're not returning */
-    if (!(stream->flags & (STREAMTCP_STREAM_FLAG_GAP|STREAMTCP_STREAM_FLAG_NOREASSEMBLY))) {
+    if (!(stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY)) {
         if (!(StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(stream))) {
             SCReturnInt(true);
         }
@@ -672,9 +672,7 @@ static inline uint64_t GetLeftEdge(TcpSession *ssn, TcpStream *stream)
     bool use_log = true;
 
     uint64_t left_edge = 0;
-    if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) ||
-          (stream->flags & STREAMTCP_STREAM_FLAG_GAP))
-    {
+    if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED)) {
         use_app = false; // app is dead
     }
 
@@ -829,10 +827,8 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags)
         StreamingBufferClear(&stream->sb);
         return;
 
-    } else if (((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) ||
-                (stream->flags & STREAMTCP_STREAM_FLAG_GAP))     &&
-               (stream->flags & STREAMTCP_STREAM_FLAG_DISABLE_RAW))
-    {
+    } else if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) &&
+               (stream->flags & STREAMTCP_STREAM_FLAG_DISABLE_RAW)) {
         SCLogDebug("ssn %p / stream %p: both app and raw are done, "
                  "STREAMTCP_STREAM_FLAG_NOREASSEMBLY set", ssn, stream);
         stream->flags |= STREAMTCP_STREAM_FLAG_NOREASSEMBLY;
index 41f75d466d5fe28373ef468d976b1b7a4bd1a6b6..b229edfae800a2df37b7eebc88b7b5136088ab1d 100644 (file)
@@ -195,8 +195,7 @@ enum TcpState
  * Per STREAM flags
  */
 
-/** stream is in a gap state */
-#define STREAMTCP_STREAM_FLAG_GAP                           BIT_U16(0)
+// bit 0 vacant
 /** Flag to avoid stream reassembly/app layer inspection for the stream */
 #define STREAMTCP_STREAM_FLAG_NOREASSEMBLY                  BIT_U16(1)
 /** we received a keep alive */
index 17c2168026c3ee0c0b7a6015939cd126f715d61d..b4aacf14fa582cd6f42defe69b7d5a6d76353aba 100644 (file)
@@ -807,9 +807,7 @@ int StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction)
     int use_app = 1;
     int use_raw = 1;
 
-    if ((ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) ||
-          (stream->flags & STREAMTCP_STREAM_FLAG_GAP))
-    {
+    if (ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) {
         // app is dead
         use_app = 0;
     }
@@ -1360,11 +1358,8 @@ void StreamReassembleRawUpdateProgress(TcpSession *ssn, Packet *p, uint64_t prog
         stream->flags &= ~STREAMTCP_STREAM_FLAG_TRIGGER_RAW;
 
     /* if app is active and beyond raw, sync raw to app */
-    } else if (progress == 0 &&
-            STREAM_APP_PROGRESS(stream) > STREAM_RAW_PROGRESS(stream) &&
-            !(ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) &&
-            !(stream->flags & STREAMTCP_STREAM_FLAG_GAP))
-    {
+    } else if (progress == 0 && STREAM_APP_PROGRESS(stream) > STREAM_RAW_PROGRESS(stream) &&
+               !(ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED)) {
         /* if trigger raw is set we sync the 2 trackers */
         if (stream->flags & STREAMTCP_STREAM_FLAG_TRIGGER_RAW)
         {
@@ -3379,7 +3374,6 @@ static int StreamTcpReassembleInlineTest08(void)
     FLOW_INITIALIZE(&f);
 
     stream_config.reassembly_toserver_chunk_size = 15;
-    ssn.client.flags |= STREAMTCP_STREAM_FLAG_GAP;
     f.protoctx = &ssn;
 
     uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' };
@@ -3431,7 +3425,6 @@ static int StreamTcpReassembleInlineTest09(void)
     FLOW_INITIALIZE(&f);
 
     stream_config.reassembly_toserver_chunk_size = 20;
-    ssn.client.flags |= STREAMTCP_STREAM_FLAG_GAP;
 
     uint8_t payload[] = { 'C', 'C', 'C', 'C', 'C' };
     Packet *p = UTHBuildPacketReal(payload, 5, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80);
index 0f49f19a96b2237109162b5502eb8dad898e772b..59c3da97ff46aa3c80ee94a00fb494a31c9fb669 100644 (file)
@@ -4832,10 +4832,7 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
             goto skip;
         }
 
-        if (p->flow->flags & FLOW_WRONG_THREAD ||
-            ssn->client.flags & STREAMTCP_STREAM_FLAG_GAP ||
-            ssn->server.flags & STREAMTCP_STREAM_FLAG_GAP)
-        {
+        if (p->flow->flags & FLOW_WRONG_THREAD) {
             /* Stream and/or session in known bad condition. Block events
              * from being set. */
             p->flags |= PKT_STREAM_NO_EVENTS;