]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: turn session bool into flag
authorVictor Julien <vjulien@oisf.net>
Sat, 11 Feb 2023 18:22:26 +0000 (19:22 +0100)
committerVictor Julien <vjulien@oisf.net>
Wed, 15 Feb 2023 11:12:07 +0000 (12:12 +0100)
src/flow-util.h
src/stream-tcp-private.h
src/stream-tcp-reassemble.c
src/stream-tcp.c

index 8c8adfc87307469c932158ad53c4142353df72de..16cca91b643b44baca604cf255211cb8eab4915c 100644 (file)
@@ -165,7 +165,7 @@ static inline void FlowEndCountersUpdate(ThreadVars *tv, FlowEndCounters *fec, F
     if (f->proto == IPPROTO_TCP && f->protoctx != NULL) {
         TcpSession *ssn = f->protoctx;
         StatsIncr(tv, fec->flow_tcp_state[ssn->state]);
-        if (ssn->lossy_be_liberal) {
+        if (ssn->flags & STREAMTCP_FLAG_LOSSY_BE_LIBERAL) {
             StatsIncr(tv, fec->flow_tcp_liberal);
         }
     }
index be304342dea376936250ad9882c8ce1e3b4204c3..6c2117a578b6e95bb6c04d40a730ad30056bf14b 100644 (file)
@@ -189,7 +189,8 @@ enum TcpState {
 #define STREAMTCP_FLAG_CLIENT_SACKOK BIT_U32(9)
 /** Flag to indicate both sides of the session permit SACK (SYN + SYN/ACK) */
 #define STREAMTCP_FLAG_SACKOK BIT_U32(10)
-// vacancy
+/** Session is in "lossy" state, be liberal */
+#define STREAMTCP_FLAG_LOSSY_BE_LIBERAL BIT_U32(11)
 /** 3WHS confirmed by server -- if suri sees 3whs ACK but server doesn't (pkt
  *  is lost on the way to server), SYN/ACK is retransmitted. If server sends
  *  normal packet we assume 3whs to be completed. Only used for SYN/ACK resend
@@ -277,7 +278,6 @@ typedef struct TcpSession_ {
     int8_t data_first_seen_dir;
     /** track all the tcp flags we've seen */
     uint8_t tcp_packet_flags;
-    bool lossy_be_liberal;
     /* coccinelle: TcpSession:flags:STREAMTCP_FLAG */
     uint32_t flags;
     uint32_t reassembly_depth; /**< reassembly depth for the stream */
index a0674c35837f345bdf6e9d23f1780faef37f662a..8ef0fcd5ff9fbbdd73af447f127ada1f0cf7257c 100644 (file)
@@ -781,7 +781,7 @@ int StreamTcpReassembleHandleSegmentHandleData(ThreadVars *tv, TcpReassemblyThre
     if (seg == NULL) {
         SCLogDebug("segment_pool is empty");
         StreamTcpSetEvent(p, STREAM_REASSEMBLY_NO_SEGMENT);
-        ssn->lossy_be_liberal = true;
+        ssn->flags |= STREAMTCP_FLAG_LOSSY_BE_LIBERAL;
         SCReturnInt(-1);
     }
 
@@ -805,7 +805,7 @@ int StreamTcpReassembleHandleSegmentHandleData(ThreadVars *tv, TcpReassemblyThre
             tv, ra_ctx, stream, seg, p, TCP_GET_SEQ(p), p->payload, p->payload_len);
     if (r < 0) {
         if (r == -ENOMEM) {
-            ssn->lossy_be_liberal = true;
+            ssn->flags |= STREAMTCP_FLAG_LOSSY_BE_LIBERAL;
         }
         SCLogDebug("StreamTcpReassembleInsertSegment failed");
         SCReturnInt(-1);
@@ -1253,7 +1253,7 @@ static int ReassembleUpdateAppLayer (ThreadVars *tv,
             StreamTcpSetEvent(p, STREAM_REASSEMBLY_SEQ_GAP);
             (*stream)->flags |= STREAMTCP_STREAM_FLAG_HAS_GAP;
             StatsIncr(tv, ra_ctx->counter_tcp_reass_gap);
-            ssn->lossy_be_liberal = true;
+            ssn->flags |= STREAMTCP_FLAG_LOSSY_BE_LIBERAL;
 
             /* AppLayerHandleTCPData has likely updated progress. */
             const bool no_progress_update = (app_progress == STREAM_APP_PROGRESS(*stream));
index b3457cb318f1ca84309824d4c51f65529b84283d..e5e52222f1ce17c2eaf8ab36bee2183cd137bd4a 100644 (file)
@@ -5516,7 +5516,7 @@ static int StreamTcpValidateRst(TcpSession *ssn, Packet *p)
 {
     uint8_t os_policy;
 
-    if (ssn->lossy_be_liberal) {
+    if (ssn->flags & STREAMTCP_FLAG_LOSSY_BE_LIBERAL) {
         SCReturnInt(1);
     }