From: Jeff Lucovsky Date: Thu, 27 Jul 2023 14:09:02 +0000 (-0400) Subject: stream/bool: Use bool for StreamTcpInlineMode X-Git-Tag: suricata-8.0.0-beta1~2065 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2016d68f414787808f6f24829d0c5a2707ff3a17;p=thirdparty%2Fsuricata.git stream/bool: Use bool for StreamTcpInlineMode --- diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 164825440f..2b8a4d079c 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -779,7 +779,7 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream) if (use_raw) { uint64_t raw_progress = STREAM_RAW_PROGRESS(stream); - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { uint32_t chunk_size = (stream == &ssn->client) ? stream_config.reassembly_toserver_chunk_size : stream_config.reassembly_toclient_chunk_size; @@ -834,14 +834,14 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream) last_ack_abs += (stream->last_ack - stream->base_seq); } /* in IDS mode we shouldn't see the base_seq pass last_ack */ - DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && StreamTcpInlineMode() == FALSE && !f->ffr && + DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && !StreamTcpInlineMode() && !f->ffr && ssn->state < TCP_CLOSED); left_edge = MIN(left_edge, last_ack_abs); /* if we're told to look for overlaps with different data we should * consider data that is ack'd as well. Injected packets may have * been ack'd or injected packet may be too late. */ - if (StreamTcpInlineMode() == FALSE && check_overlap_different_data) { + if (!StreamTcpInlineMode() && check_overlap_different_data) { const uint32_t window = stream->window ? stream->window : 4096; if (window < left_edge) left_edge -= window; diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 737b222d53..06992da791 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -421,7 +421,7 @@ uint64_t StreamTcpGetAcked(const TcpStream *stream) uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof) { uint64_t right_edge = STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq; - if (!eof && StreamTcpInlineMode() == FALSE) { + if (!eof && !StreamTcpInlineMode()) { right_edge = MIN(GetAbsLastAck(stream), right_edge); } return right_edge; @@ -430,7 +430,7 @@ uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof) uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof) { uint64_t right_edge = StreamingBufferGetConsecutiveDataRightEdge(&stream->sb); - if (!eof && StreamTcpInlineMode() == FALSE) { + if (!eof && !StreamTcpInlineMode()) { right_edge = MIN(GetAbsLastAck(stream), right_edge); } return right_edge; @@ -496,7 +496,7 @@ static int StreamTcpReassemblyConfig(bool quiet) if (overlap_diff_data) { StreamTcpReassembleConfigEnableOverlapCheck(); } - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { StreamTcpReassembleConfigEnableOverlapCheck(); } @@ -1189,7 +1189,7 @@ static inline uint32_t AdjustToAcked(const Packet *p, uint32_t adjusted = data_len; /* get window of data that is acked */ - if (StreamTcpInlineMode() == FALSE) { + if (!StreamTcpInlineMode()) { SCLogDebug("ssn->state %s", StreamTcpStateAsString(ssn->state)); if (data_len == 0 || ((ssn->state < TCP_CLOSED || (ssn->state == TCP_CLOSED && @@ -1481,7 +1481,7 @@ bool StreamReassembleRawHasDataReady(TcpSession *ssn, Packet *p) STREAMTCP_STREAM_FLAG_DISABLE_RAW)) return false; - if (StreamTcpInlineMode() == FALSE) { + if (!StreamTcpInlineMode()) { const uint64_t segs_re_abs = STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq; if (STREAM_RAW_PROGRESS(stream) == segs_re_abs) { @@ -1860,7 +1860,7 @@ int StreamReassembleRaw(TcpSession *ssn, const Packet *p, uint64_t *progress_out, bool respect_inspect_depth) { /* handle inline separately as the logic is very different */ - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { return StreamReassembleRawInline(ssn, p, Callback, cb_data, progress_out); } diff --git a/src/stream-tcp.c b/src/stream-tcp.c index d76a0593a0..d41110aac5 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -6851,9 +6851,9 @@ int StreamTcpBypassEnabled(void) * \retval 0 no * \retval 1 yes */ -int StreamTcpInlineMode(void) +bool StreamTcpInlineMode(void) { - return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE) ? 1 : 0; + return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE); } diff --git a/src/stream-tcp.h b/src/stream-tcp.h index 3246712459..ff8a0998cb 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -191,7 +191,7 @@ void StreamTcpSessionCleanup(TcpSession *ssn); void StreamTcpStreamCleanup(TcpStream *stream); /* check if bypass is enabled */ int StreamTcpBypassEnabled(void); -int StreamTcpInlineMode(void); +bool StreamTcpInlineMode(void); int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn);