stream-tcp: use flags field to store inline info

pull/2752/head
Eric Leblond 8 years ago committed by Victor Julien
parent 85dab65414
commit 7a17b4acf5

@ -33,20 +33,6 @@
#include "util-unittest.h"
#include "util-unittest-helper.h"
/** defined in stream-tcp-reassemble.c */
extern int stream_inline;
/**
* \brief See if stream engine is operating in inline mode
*
* \retval 0 no
* \retval 1 yes
*/
int StreamTcpInlineMode(void)
{
return stream_inline;
}
/**
* \brief Compare the shared data portion of two segments
*

@ -26,7 +26,6 @@
#include "stream-tcp-private.h"
int StreamTcpInlineMode(void);
int StreamTcpInlineSegmentCompare(TcpStream *, Packet *, TcpSegment *);
void StreamTcpInlineSegmentReplacePacket(TcpStream *, Packet *, TcpSegment *);

@ -40,8 +40,6 @@
/* unittest helper functions */
extern int stream_inline;
void StreamTcpUTInit(TcpReassemblyThreadCtx **ra_ctx)
{
StreamTcpInitConfig(TRUE);
@ -52,11 +50,11 @@ void StreamTcpUTDeinit(TcpReassemblyThreadCtx *ra_ctx)
{
StreamTcpReassembleFreeThreadCtx(ra_ctx);
StreamTcpFreeConfig(TRUE);
stream_inline = 0;
stream_config.flags &= ~STREAMTCP_INIT_FLAG_INLINE;
}
void StreamTcpUTInitInline(void) {
stream_inline = 1;
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
void StreamTcpUTSetupSession(TcpSession *ssn)

@ -115,9 +115,6 @@ static uint64_t ssn_pool_cnt = 0; /** counts ssns, protected by ssn_pool_mutex *
uint64_t StreamTcpReassembleMemuseGlobalCounter(void);
SC_ATOMIC_DECLARE(uint64_t, st_memuse);
/* stream engine running in "inline" mode. */
int stream_inline = 0;
void StreamTcpInitMemuse(void)
{
SC_ATOMIC_INIT(st_memuse);
@ -309,7 +306,8 @@ static void StreamTcpSessionPoolCleanup(void *s)
*/
int StreamTcpInlineDropInvalid(void)
{
return (stream_inline && (stream_config.flags & STREAMTCP_INIT_FLAG_DROP_INVALID));
return ((stream_config.flags & STREAMTCP_INIT_FLAG_INLINE)
&& (stream_config.flags & STREAMTCP_INIT_FLAG_DROP_INVALID));
}
/** \brief To initialize the stream global configuration data
@ -405,24 +403,24 @@ void StreamTcpInitConfig(char quiet)
* backward compatibility */
if (strcmp(temp_stream_inline_str, "auto") == 0) {
if (EngineModeIsIPS()) {
stream_inline = 1;
} else {
stream_inline = 0;
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
} else if (ConfGetBool("stream.inline", &inl) == 1) {
stream_inline = inl;
if (inl) {
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
}
} else {
/* default to 'auto' */
if (EngineModeIsIPS()) {
stream_inline = 1;
} else {
stream_inline = 0;
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
}
if (!quiet) {
SCLogConfig("stream.\"inline\": %s", stream_inline ? "enabled" : "disabled");
SCLogConfig("stream.\"inline\": %s",
stream_config.flags & STREAMTCP_INIT_FLAG_INLINE
? "enabled" : "disabled");
}
int bypass = 0;
@ -5898,7 +5896,8 @@ int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback
/* for IDS, return ack'd segments. For IPS all. */
TcpSegment *seg = stream->seg_list;
for (; seg != NULL &&
(stream_inline || SEQ_LT(seg->seq, stream->last_ack));)
((stream_config.flags & STREAMTCP_INIT_FLAG_INLINE)
|| SEQ_LT(seg->seq, stream->last_ack));)
{
const uint8_t *seg_data;
uint32_t seg_datalen;
@ -5920,6 +5919,18 @@ int StreamTcpBypassEnabled(void)
return (stream_config.flags & STREAMTCP_INIT_FLAG_BYPASS);
}
/**
* \brief See if stream engine is operating in inline mode
*
* \retval 0 no
* \retval 1 yes
*/
int StreamTcpInlineMode(void)
{
return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE) ? 1 : 0;
}
void TcpSessionSetReassemblyDepth(TcpSession *ssn, uint32_t size)
{
if (size > ssn->reassembly_depth || size == 0) {

@ -36,6 +36,7 @@
#define STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION BIT_U8(0)
#define STREAMTCP_INIT_FLAG_DROP_INVALID BIT_U8(1)
#define STREAMTCP_INIT_FLAG_BYPASS BIT_U8(2)
#define STREAMTCP_INIT_FLAG_INLINE BIT_U8(3)
/*global flow data*/
typedef struct TcpStreamCnf_ {
@ -213,6 +214,7 @@ void StreamTcpStreamCleanup(TcpStream *stream);
/* check if bypass is enabled */
int StreamTcpBypassEnabled(void);
int StreamTcpInlineDropInvalid(void);
int StreamTcpInlineMode(void);
int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn);

Loading…
Cancel
Save