stream: improve needs reassembly code

pull/2673/head
Victor Julien 9 years ago
parent 55e19bfb89
commit 04b24cf24e

@ -304,8 +304,8 @@ int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client)
SCReturnInt(0); SCReturnInt(0);
} }
*client = StreamNeedsReassembly(ssn, 0); *client = StreamNeedsReassembly(ssn, STREAM_TOSERVER);
*server = StreamNeedsReassembly(ssn, 1); *server = StreamNeedsReassembly(ssn, STREAM_TOCLIENT);
/* if state is not fully closed we assume that we haven't fully /* if state is not fully closed we assume that we haven't fully
* inspected the app layer state yet */ * inspected the app layer state yet */

@ -762,14 +762,13 @@ static int StreamTcpReassembleRawCheckLimit(const TcpSession *ssn,
/** /**
* \brief see what if any work the TCP session still needs * \brief see what if any work the TCP session still needs
*/ */
int StreamNeedsReassembly(TcpSession *ssn, int direction) int StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction)
{ {
TcpStream *stream = NULL; const TcpStream *stream = NULL;
#ifdef DEBUG #ifdef DEBUG
char *dirstr = NULL; char *dirstr = NULL;
#endif #endif
/* TODO use STREAM_TOCLIENT/STREAM_TOSERVER */ if (direction == STREAM_TOSERVER) {
if (direction == 0) {
stream = &ssn->client; stream = &ssn->client;
#ifdef DEBUG #ifdef DEBUG
dirstr = "client"; dirstr = "client";
@ -796,31 +795,25 @@ int StreamNeedsReassembly(TcpSession *ssn, int direction)
use_raw = 0; use_raw = 0;
} }
if (stream->seg_list_tail != NULL) { uint64_t right_edge = STREAM_BASE_OFFSET(stream) + stream->sb.buf_offset;
uint64_t right_edge = TCP_SEG_OFFSET(stream->seg_list_tail) +
TCP_SEG_LEN(stream->seg_list_tail);
SCLogDebug("%s: list %p app %"PRIu64" (use: %s), raw %"PRIu64" (use: %s). Stream right edge: %"PRIu64, SCLogDebug("%s: list %p app %"PRIu64" (use: %s), raw %"PRIu64" (use: %s). Stream right edge: %"PRIu64,
dirstr, dirstr,
stream->seg_list, stream->seg_list,
STREAM_APP_PROGRESS(stream), use_app ? "yes" : "no", STREAM_APP_PROGRESS(stream), use_app ? "yes" : "no",
STREAM_RAW_PROGRESS(stream), use_raw ? "yes" : "no", STREAM_RAW_PROGRESS(stream), use_raw ? "yes" : "no",
right_edge); right_edge);
if (use_raw) {
if (use_raw) { if (right_edge > STREAM_RAW_PROGRESS(stream)) {
if (right_edge > STREAM_RAW_PROGRESS(stream)) { SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION", dirstr);
SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION", dirstr); return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
}
} }
if (use_app) { }
if (right_edge > STREAM_APP_PROGRESS(stream)) { if (use_app) {
SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION", dirstr); if (right_edge > STREAM_APP_PROGRESS(stream)) {
return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION; SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION", dirstr);
} return STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
} }
} else {
SCLogDebug("%s: no list", dirstr);
} }
SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NONE", dirstr); SCLogDebug("%s: STREAM_HAS_UNPROCESSED_SEGMENTS_NONE", dirstr);

@ -187,7 +187,7 @@ enum {
}; };
TmEcode StreamTcp (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); TmEcode StreamTcp (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
int StreamNeedsReassembly(TcpSession *ssn, int direction); int StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction);
TmEcode StreamTcpThreadInit(ThreadVars *, void *, void **); TmEcode StreamTcpThreadInit(ThreadVars *, void *, void **);
TmEcode StreamTcpThreadDeinit(ThreadVars *tv, void *data); TmEcode StreamTcpThreadDeinit(ThreadVars *tv, void *data);
void StreamTcpRegisterTests (void); void StreamTcpRegisterTests (void);

Loading…
Cancel
Save