flow-time: handle detect-less case

Flow timeout code keeps track of thread module running detect, and
fails (hard) if it doesn't find it.

This changeset retrieves the global g_detect_disabled and passes
it to the timeout handling code during setup.
pull/796/head
Victor Julien 13 years ago
parent 258778cde4
commit dfda0cd4b6

@ -365,6 +365,8 @@ next:
return cnt; return cnt;
} }
extern int g_detect_disabled;
/** \brief Thread that manages the flow table and times out flows. /** \brief Thread that manages the flow table and times out flows.
* *
* \param td ThreadVars casted to void ptr * \param td ThreadVars casted to void ptr
@ -424,7 +426,7 @@ void *FlowManagerThread(void *td)
memset(&ts, 0, sizeof(ts)); memset(&ts, 0, sizeof(ts));
FlowForceReassemblySetup(); FlowForceReassemblySetup(g_detect_disabled);
/* set the thread name */ /* set the thread name */
if (SCSetThreadName(th_v->name) < 0) { if (SCSetThreadName(th_v->name) < 0) {

@ -718,7 +718,10 @@ void FlowForceReassembly(void)
return; return;
} }
void FlowForceReassemblySetup(void) /**
* \param detect_disabled bool, indicating if we use a detection engine (true)
*/
void FlowForceReassemblySetup(int detect_disabled)
{ {
/* get StreamTCP TM's slot and TV containing this slot */ /* get StreamTCP TM's slot and TV containing this slot */
stream_pseudo_pkt_stream_tm_slot = TmSlotGetSlotForTM(TMM_STREAMTCP); stream_pseudo_pkt_stream_tm_slot = TmSlotGetSlotForTM(TMM_STREAMTCP);
@ -737,27 +740,29 @@ void FlowForceReassemblySetup(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* get detect TM's slot and TV containing this slot */ if (!detect_disabled) {
stream_pseudo_pkt_detect_tm_slot = TmSlotGetSlotForTM(TMM_DETECT); /* get detect TM's slot and TV containing this slot */
if (stream_pseudo_pkt_detect_tm_slot == NULL) { stream_pseudo_pkt_detect_tm_slot = TmSlotGetSlotForTM(TMM_DETECT);
/* yes, this is fatal! */ if (stream_pseudo_pkt_detect_tm_slot == NULL) {
SCLogError(SC_ERR_TM_MODULES_ERROR, "Looks like we have failed to " /* yes, this is fatal! */
"retrieve a slot for DETECT TM"); SCLogError(SC_ERR_TM_MODULES_ERROR, "Looks like we have failed to "
exit(EXIT_FAILURE); "retrieve a slot for DETECT TM");
} exit(EXIT_FAILURE);
stream_pseudo_pkt_detect_TV = }
TmThreadsGetTVContainingSlot(stream_pseudo_pkt_detect_tm_slot); stream_pseudo_pkt_detect_TV =
if (stream_pseudo_pkt_detect_TV == NULL) { TmThreadsGetTVContainingSlot(stream_pseudo_pkt_detect_tm_slot);
/* yes, this is fatal! */ if (stream_pseudo_pkt_detect_TV == NULL) {
SCLogError(SC_ERR_TM_MODULES_ERROR, "Looks like we have failed to " /* yes, this is fatal! */
"retrieve the TV containing the Detect TM slot"); SCLogError(SC_ERR_TM_MODULES_ERROR, "Looks like we have failed to "
exit(EXIT_FAILURE); "retrieve the TV containing the Detect TM slot");
} exit(EXIT_FAILURE);
if (stream_pseudo_pkt_detect_TV->tm_slots == stream_pseudo_pkt_detect_tm_slot) { }
stream_pseudo_pkt_detect_prev_TV = stream_pseudo_pkt_detect_TV->prev; if (stream_pseudo_pkt_detect_TV->tm_slots == stream_pseudo_pkt_detect_tm_slot) {
} stream_pseudo_pkt_detect_prev_TV = stream_pseudo_pkt_detect_TV->prev;
if (strcasecmp(stream_pseudo_pkt_detect_TV->outqh_name, "packetpool") == 0) { }
stream_pseudo_pkt_detect_TV = NULL; if (strcasecmp(stream_pseudo_pkt_detect_TV->outqh_name, "packetpool") == 0) {
stream_pseudo_pkt_detect_TV = NULL;
}
} }
SCMutexLock(&tv_root_lock); SCMutexLock(&tv_root_lock);

@ -27,6 +27,6 @@
int FlowForceReassemblyForFlowV2(Flow *f, int server, int client); int FlowForceReassemblyForFlowV2(Flow *f, int server, int client);
int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client); int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client);
void FlowForceReassembly(void); void FlowForceReassembly(void);
void FlowForceReassemblySetup(void); void FlowForceReassemblySetup(int detect_disabled);
#endif /* __FLOW_TIMEOUT_H__ */ #endif /* __FLOW_TIMEOUT_H__ */

Loading…
Cancel
Save