]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
fix daq break
authorRuss Combs <rucombs@cisco.com>
Wed, 26 Nov 2014 12:57:12 +0000 (07:57 -0500)
committerRuss Combs <rucombs@cisco.com>
Wed, 26 Nov 2014 12:57:12 +0000 (07:57 -0500)
src/main/analyzer.cc
src/main/analyzer.h
src/main/snort.cc
src/packet_io/sfdaq.cc
src/packet_io/sfdaq.h

index 046fdad028f768207d16bf068389eb5152cdc1a7..ecbccdc183bbbfb7546aecc879b9d86926caf725 100644 (file)
@@ -46,6 +46,7 @@ Analyzer::Analyzer(const char* s)
     source = s;
     command = AC_NONE;
     swap = nullptr;
+    daqh = nullptr;
 }
 
 void Analyzer::operator()(unsigned id, Swapper* ps)
@@ -55,6 +56,7 @@ void Analyzer::operator()(unsigned id, Swapper* ps)
 
     pin_thread_to_cpu(source);
     snort_thread_init(source);
+    daqh = DAQ_GetHandle();
 
     analyze();
 
@@ -69,10 +71,14 @@ bool Analyzer::execute(AnalyzerCommand ac)
     if ( command && command != AC_PAUSE )
         return false;
 
+    if ( ac == AC_STOP )
+        DAQ_BreakLoop(-1, daqh);
+
     // FIXIT-L executing a command while paused
     // will cause a resume
     command = ac;
     take_break();
+
     return true;
 }
 
index 773e25048fa9697497b1e686d5ab4d1a40b65957..045f30d9ad1bf3fb68f8982125216dd927c3e71c 100644 (file)
@@ -62,6 +62,7 @@ private:
     const char* source;
     volatile AnalyzerCommand command;
     Swapper* swap;
+    void* daqh;
 };
 
 #endif
index 225faa00b12b73a7154189a55dc22c35e4e6bca4..40a9cdb56623b8b4090963a19c8051a2d4a77677 100644 (file)
@@ -840,7 +840,7 @@ DAQ_Verdict packet_callback(
     if ( snort_conf->pkt_cnt && pc.total_from_daq >= snort_conf->pkt_cnt )
         DAQ_BreakLoop(-1);
 
-    if ( break_time() )
+    else if ( break_time() )
         DAQ_BreakLoop(0);
 
     MODULE_PROFILE_END(totalPerfStats);
index e56ade841b9e4d0beca4306697af860fb0f5b285..2990e6be7531c97e0e1ee6ee16a7482845d73140 100644 (file)
@@ -543,10 +543,17 @@ int DAQ_Inject(const DAQ_PktHdr_t* h, int rev, const uint8_t* buf, uint32_t len)
     return err;
 }
 
-int DAQ_BreakLoop (int error)
+//--------------------------------------------------------------------
+
+void* DAQ_GetHandle()
+{ return daq_hand; }
+
+int DAQ_BreakLoop (int error, void* hand)
 {
+    if ( !hand )
+        hand = daq_hand;
     s_error = error;
-    return ( daq_breakloop(daq_mod, daq_hand) == DAQ_SUCCESS );
+    return ( daq_breakloop(daq_mod, hand) == DAQ_SUCCESS );
 }
 
 //--------------------------------------------------------------------
index 3d932dc680139b84aff096e4deb2132f0086b256..c7585250d3f2ea37aad640b4a3a9b93d4b248031 100644 (file)
@@ -76,7 +76,10 @@ int DAQ_Stop(void);
 // (but only where performance justifies exposing implementation!)
 int DAQ_Acquire(int max, DAQ_Analysis_Func_t, uint8_t* user);
 int DAQ_Inject(const DAQ_PktHdr_t*, int rev, const uint8_t* buf, uint32_t len);
-int DAQ_BreakLoop(int error);
+
+void* DAQ_GetHandle();
+int DAQ_BreakLoop(int error, void* handle = nullptr);
+
 #ifdef HAVE_DAQ_ACQUIRE_WITH_META
 void DAQ_Set_MetaCallback(DAQ_Meta_Func_t meta_callback);
 #endif