-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow timeout timing/v14 #12084
base: master
Are you sure you want to change the base?
Flow timeout timing/v14 #12084
Changes from all commits
cf4a3cf
8f3c6bd
858453d
44592ec
b1140ea
c80afe7
78b8898
9bc1c59
a516c42
22683e0
5411384
663eefc
ef672b3
2b8351f
add7b78
b1ea592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,9 @@ void FlowDisableFlowManagerThread(void) | |
|
||
/** \internal | ||
* \brief check if a flow is timed out | ||
* Takes lastts, adds the timeout policy to it, compared to current time `ts`. | ||
* In case of emergency mode, timeout_policy is ignored and the emerg table | ||
* is used. | ||
* | ||
* \param f flow | ||
* \param ts timestamp | ||
|
@@ -182,17 +185,30 @@ void FlowDisableFlowManagerThread(void) | |
*/ | ||
static bool FlowManagerFlowTimeout(Flow *f, SCTime_t ts, uint32_t *next_ts, const bool emerg) | ||
{ | ||
uint32_t flow_times_out_at = f->timeout_at; | ||
SCTime_t timesout_at; // = f->lastts; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About the comment: why? |
||
|
||
if (emerg) { | ||
extern FlowProtoTimeout flow_timeouts_delta[FLOW_PROTO_MAX]; | ||
flow_times_out_at -= FlowGetFlowTimeoutDirect(flow_timeouts_delta, f->flow_state, f->protomap); | ||
extern FlowProtoTimeout flow_timeouts_emerg[FLOW_PROTO_MAX]; | ||
timesout_at = SCTIME_ADD_SECS(f->lastts, | ||
FlowGetFlowTimeoutDirect(flow_timeouts_emerg, f->flow_state, f->protomap)); | ||
} else { | ||
timesout_at = SCTIME_ADD_SECS(f->lastts, f->timeout_policy); | ||
} | ||
if (*next_ts == 0 || flow_times_out_at < *next_ts) | ||
*next_ts = flow_times_out_at; | ||
if (*next_ts == 0 || (uint32_t)SCTIME_SECS(timesout_at) < *next_ts) | ||
*next_ts = (uint32_t)SCTIME_SECS(timesout_at); | ||
|
||
/* do the timeout check */ | ||
if ((uint64_t)flow_times_out_at >= SCTIME_SECS(ts)) { | ||
return false; | ||
/* if time is live, we just use the tts */ | ||
if (TimeModeIsLive() || f->thread_id[0] == 0) { | ||
/* do the timeout check */ | ||
if (SCTIME_CMP_LT(ts, timesout_at)) { | ||
return false; | ||
} | ||
} else { | ||
SCTime_t checkts = TmThreadsGetThreadTime(f->thread_id[0]); | ||
/* do the timeout check */ | ||
if (SCTIME_CMP_LT(checkts, timesout_at)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
|
@@ -326,22 +342,23 @@ static void FlowManagerHashRowTimeout(FlowManagerTimeoutThread *td, Flow *f, SCT | |
do { | ||
checked++; | ||
|
||
FLOWLOCK_WRLOCK(f); | ||
|
||
/* check flow timeout based on lastts and state. Both can be | ||
* accessed w/o Flow lock as we do have the hash row lock (so flow | ||
* can't disappear) and flow_state is atomic. lastts can only | ||
* be modified when we have both the flow and hash row lock */ | ||
|
||
/* timeout logic goes here */ | ||
if (FlowManagerFlowTimeout(f, ts, next_ts, emergency) == false) { | ||
FLOWLOCK_UNLOCK(f); | ||
counters->flows_notimeout++; | ||
|
||
prev_f = f; | ||
f = f->next; | ||
continue; | ||
} | ||
|
||
FLOWLOCK_WRLOCK(f); | ||
|
||
Flow *next_flow = f->next; | ||
|
||
#ifdef CAPTURE_OFFLOAD | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,11 +554,6 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) | |
|
||
SCLogDebug("packet %"PRIu64, p->pcap_cnt); | ||
|
||
/* update time */ | ||
if (!(PKT_IS_PSEUDOPKT(p))) { | ||
TimeSetByThread(tv->id, p->ts); | ||
} | ||
|
||
/* handle Flow */ | ||
if (p->flags & PKT_WANTS_FLOW) { | ||
FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_FLOW); | ||
|
@@ -567,6 +562,10 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) | |
if (likely(p->flow != NULL)) { | ||
DEBUG_ASSERT_FLOW_LOCKED(p->flow); | ||
if (FlowUpdate(tv, fw, p) == TM_ECODE_DONE) { | ||
/* update time */ | ||
if (!(PKT_IS_PSEUDOPKT(p))) { | ||
TimeSetByThread(tv->id, p->ts); | ||
} | ||
goto housekeeping; | ||
} | ||
} | ||
|
@@ -581,6 +580,11 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data) | |
DEBUG_VALIDATE_BUG_ON(p->pkt_src != PKT_SRC_FFR); | ||
} | ||
|
||
/* update time */ | ||
if (!(PKT_IS_PSEUDOPKT(p))) { | ||
TimeSetByThread(tv->id, p->ts); | ||
} | ||
|
||
Comment on lines
+583
to
+587
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we merge it w the |
||
SCLogDebug("packet %"PRIu64" has flow? %s", p->pcap_cnt, p->flow ? "yes" : "no"); | ||
|
||
/* handle TCP and app layer */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,7 @@ static OutputInitResult EveStreamLogInitCtxSub(ConfNode *conf, OutputCtx *parent | |
ctx->trigger_flags |= SetFlag(conf, "state-update", STREAM_PKT_FLAG_STATE_UPDATE); | ||
ctx->trigger_flags |= | ||
SetFlag(conf, "spurious-retransmission", STREAM_PKT_FLAG_SPURIOUS_RETRANSMISSION); | ||
ctx->trigger_flags |= SetFlag(conf, "tcp-port-reuse", STREAM_PKT_FLAG_TCP_PORT_REUSE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Why is it called "port" reuse? |
||
|
||
ctx->trigger_flags |= SetFlag(conf, "all", 0xFFFF); | ||
SCLogDebug("trigger_flags %04x", ctx->trigger_flags); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to do the same thing in both the blocks? Can we merge them? Then it becomes similar to flow manager..