static TmSlot *stream_pseudo_pkt_decode_tm_slot = NULL;
static ThreadVars *stream_pseudo_pkt_decode_TV = NULL;
+/**
+ * \internal
+ * \brief Flush out if we have any unattended packets.
+ */
+static inline void FlowForceReassemblyFlushPendingPseudoPackets(void)
+{
+ /* we don't lock the queue, since flow manager is dead */
+ if (stream_pseudo_pkt_decode_tm_slot->slot_post_pq.len == 0)
+ return;
+
+ SCMutexLock(&stream_pseudo_pkt_decode_tm_slot->slot_post_pq.mutex_q);
+ Packet *p = PacketDequeue(&stream_pseudo_pkt_decode_tm_slot->slot_post_pq);
+ SCMutexUnlock(&stream_pseudo_pkt_decode_tm_slot->slot_post_pq.mutex_q);
+ if (TmThreadsSlotProcessPkt(stream_pseudo_pkt_decode_TV,
+ stream_pseudo_pkt_decode_tm_slot,
+ p) != TM_ECODE_OK) {
+ SCLogError(SC_ERR_TM_THREADS_ERROR, "Received error from FFR on "
+ "flushing packets through decode->.. TMs");
+ }
+
+ return;
+}
+
/**
* \internal
* \brief Pseudo packet setup for flow forced reassembly.
{
/* Do remember. We need to have packet acquire disabled by now */
- /** ----- Part 1 ----- **/
+ /** ----- Part 1 ------*/
+ /* Flush out unattended packets */
+ FlowForceReassemblyFlushPendingPseudoPackets();
+
+ /** ----- Part 2 ----- **/
/* Check if all threads are idle. We need this so that we have all
* packets freeds. As a consequence, no flows are in use */
SCMutexUnlock(&tv_root_lock);
- /** ----- Part 2 ----- **/
+ /** ----- Part 3 ----- **/
/* Carry out flow reassembly for unattended flows */
FlowForceReassemblyForHash();
}
+ /* nfq */
TmModuleReceiveNFQRegister();
TmModuleVerdictNFQRegister();
TmModuleDecodeNFQRegister();
+ /* ipfw */
TmModuleReceiveIPFWRegister();
TmModuleVerdictIPFWRegister();
TmModuleDecodeIPFWRegister();
+ /* pcap live */
TmModuleReceivePcapRegister();
TmModuleDecodePcapRegister();
+ /* pcap file */
+ TmModuleReceivePcapFileRegister();
+ TmModuleDecodePcapFileRegister();
+ /* af-packet */
TmModuleReceiveAFPRegister();
TmModuleDecodeAFPRegister();
+ /* pfring */
TmModuleReceivePfringRegister();
TmModuleDecodePfringRegister();
- TmModuleReceivePcapFileRegister();
- TmModuleDecodePcapFileRegister();
+ /* dag file */
+ TmModuleReceiveErfFileRegister();
+ TmModuleDecodeErfFileRegister();
+ /* dag live */
+ TmModuleReceiveErfDagRegister();
+ TmModuleDecodeErfDagRegister();
+ /* napatech */
+ TmModuleNapatechFeedRegister();
+ TmModuleNapatechDecodeRegister();
+
+ /* stream engine */
+ TmModuleStreamTcpRegister();
+ /* detection */
TmModuleDetectRegister();
- TmModuleAlertFastLogRegister();
- TmModuleAlertDebugLogRegister();
- TmModuleAlertPreludeRegister();
+ /* respond-reject */
TmModuleRespondRejectRegister();
+
+ /* fast log */
+ TmModuleAlertFastLogRegister();
TmModuleAlertFastLogIPv4Register();
TmModuleAlertFastLogIPv6Register();
+ /* debug log */
+ TmModuleAlertDebugLogRegister();
+ /* prelue log */
+ TmModuleAlertPreludeRegister();
+ /* syslog log */
+ TmModuleAlertSyslogRegister();
TmModuleAlertSyslogIPv4Register();
TmModuleAlertSyslogIPv6Register();
+ /* unified2 log */
TmModuleUnified2AlertRegister();
- TmModuleAlertSyslogRegister();
+ /* pcap info log */
TmModuleAlertPcapInfoRegister();
+ /* drop log */
TmModuleLogDropLogRegister();
- TmModuleStreamTcpRegister();
+ /* http log */
TmModuleLogHttpLogRegister();
TmModuleLogHttpLogIPv4Register();
TmModuleLogHttpLogIPv6Register();
+ /* pcap log */
TmModulePcapLogRegister();
+ /* file log */
TmModuleLogFileLogRegister();
TmModuleLogFilestoreRegister();
+ /* cuda */
#ifdef __SC_CUDA_SUPPORT__
TmModuleCudaMpmB2gRegister();
TmModuleCudaPacketBatcherRegister();
#endif
- TmModuleReceiveErfFileRegister();
- TmModuleDecodeErfFileRegister();
- TmModuleReceiveErfDagRegister();
- TmModuleDecodeErfDagRegister();
- TmModuleNapatechFeedRegister();
- TmModuleNapatechDecodeRegister();
TmModuleDebugList();
AppLayerHtpNeedFileInspection();
FlowKillFlowManagerThread();
/* Disable packet acquire thread first */
- TmThreadDisableReceiveThreads();
+ TmThreadDisableThreadsWithTMS(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM);
FlowForceReassembly();
if (rule_reload == 1) {
/* Disable detect threads first. This is required by live rule swap */
- TmThreadDisableUptoDetectThreads();
+ TmThreadDisableThreadsWithTMS(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM |
+ TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM);
/* wait if live rule swap is in progress */
if (UtilSignalIsHandler(SIGUSR2, SignalHandlerSigusr2Idle)) {
}
/**
- * \brief Disable receive threads.
+ * \brief Disable all threads having the specified TMs.
*/
-void TmThreadDisableReceiveThreads(void)
-{
- /* value in seconds */
-#define THREAD_KILL_MAX_WAIT_TIME 60
- /* value in microseconds */
-#define WAIT_TIME 100
-
- double total_wait_time = 0;
-
- ThreadVars *tv = NULL;
-
- SCMutexLock(&tv_root_lock);
-
- /* all receive threads are part of packet processing threads */
- tv = tv_root[TVT_PPT];
-
- /* we do have to keep in mind that TVs are arranged in the order
- * right from receive to log. The moment we fail to find a
- * receive TM amongst the slots in a tv, it indicates we are done
- * with all receive threads */
- while (tv) {
- /* obtain the slots for this TV */
- TmSlot *slots = tv->tm_slots;
- TmModule *tm = TmModuleGetById(slots->tm_id);
-
- if (!(tm->flags & TM_FLAG_RECEIVE_TM)) {
- tv = tv->next;
- continue;
- }
-
- /* we found our receive TV. Send it a KILL signal. This is all
- * we need to do to kill receive threads */
- TmThreadsSetFlag(tv, THV_KILL);
-
- while (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
- usleep(WAIT_TIME);
- total_wait_time += WAIT_TIME / 1000000.0;
- if (total_wait_time > THREAD_KILL_MAX_WAIT_TIME) {
- SCLogError(SC_ERR_FATAL, "Engine unable to "
- "disable receive thread - \"%s\". "
- "Killing engine", tv->name);
- exit(EXIT_FAILURE);
- }
- }
-
- tv = tv->next;
- }
-
- SCMutexUnlock(&tv_root_lock);
-
- return;
-}
-
-/**
- * \brief Disable all threads <= detect.
- */
-void TmThreadDisableUptoDetectThreads(void)
+void TmThreadDisableThreadsWithTMS(uint8_t tm_flags)
{
/* value in seconds */
#define THREAD_KILL_MAX_WAIT_TIME 60
while (slots != NULL) {
TmModule *tm = TmModuleGetById(slots->tm_id);
- if (tm->flags & (TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM |
- TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM)) {
+ if (tm->flags & tm_flags) {
disable = 1;
break;
}
TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot);
ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *);
-void TmThreadDisableReceiveThreads(void);
-void TmThreadDisableUptoDetectThreads(void);
+void TmThreadDisableThreadsWithTMS(uint8_t tm_flags);
TmSlot *TmThreadGetFirstTmSlotForPartialPattern(const char *);
/**