From: Victor Julien Date: Sat, 11 Feb 2023 18:22:26 +0000 (+0100) Subject: stream: turn session bool into flag X-Git-Tag: suricata-7.0.0-rc2~570 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65f28b075f97c3a33e55a1218dbb814141fc6407;p=thirdparty%2Fsuricata.git stream: turn session bool into flag --- diff --git a/src/flow-util.h b/src/flow-util.h index 8c8adfc873..16cca91b64 100644 --- a/src/flow-util.h +++ b/src/flow-util.h @@ -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); } } diff --git a/src/stream-tcp-private.h b/src/stream-tcp-private.h index be304342de..6c2117a578 100644 --- a/src/stream-tcp-private.h +++ b/src/stream-tcp-private.h @@ -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 */ diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index a0674c3583..8ef0fcd5ff 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -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)); diff --git a/src/stream-tcp.c b/src/stream-tcp.c index b3457cb318..e5e52222f1 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -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); }