@@ -260,9 +260,8 @@ void NHTFlowCache::create_record(const Packet& packet, size_t flow_index, size_t
260260 m_flow_table[flow_index]->create (packet, hash_value);
261261 const size_t post_create_return_flags = plugins_post_create (m_flow_table[flow_index]->m_flow , packet);
262262 if (post_create_return_flags & ProcessPlugin::FlowAction::FLUSH) {
263- if (try_to_export (flow_index, false , packet.ts )) {
264- m_cache_stats.flushed ++;
265- }
263+ export_flow (flow_index);
264+ m_cache_stats.flushed ++;
266265 }
267266#ifdef WITH_CTT
268267 // if metadata are valid, add flow hash ctt to the flow record
@@ -271,6 +270,11 @@ void NHTFlowCache::create_record(const Packet& packet, size_t flow_index, size_t
271270 }
272271 m_flow_table[flow_index]->m_flow .flow_hash_ctt = packet.cttmeta .flow_hash ;
273272 if (only_metadata_required (m_flow_table[flow_index]->m_flow )) {
273+ if (m_hashes_in_ctt.find (m_flow_table[flow_index]->m_flow .flow_hash_ctt ) != m_hashes_in_ctt.end ())
274+ {
275+ throw " hash collision in create record!" ;
276+ }
277+ m_hashes_in_ctt.insert (m_flow_table[flow_index]->m_flow .flow_hash_ctt );
274278 m_ctt_controller.create_record (m_flow_table[flow_index]->m_flow .flow_hash_ctt , m_flow_table[flow_index]->m_flow .time_first );
275279 m_flow_table[flow_index]->is_in_ctt = true ;
276280 }
@@ -284,6 +288,11 @@ void NHTFlowCache::try_to_add_flow_to_ctt(size_t flow_index) noexcept
284288 return ;
285289 }
286290 if (only_metadata_required (m_flow_table[flow_index]->m_flow )) {
291+ if (m_hashes_in_ctt.find (m_flow_table[flow_index]->m_flow .flow_hash_ctt ) != m_hashes_in_ctt.end ())
292+ {
293+ throw " hash collision in try_to_add_flow_to_ctt!" ;
294+ }
295+ m_hashes_in_ctt.insert (m_flow_table[flow_index]->m_flow .flow_hash_ctt );
287296 m_ctt_controller.create_record (m_flow_table[flow_index]->m_flow .flow_hash_ctt , m_flow_table[flow_index]->m_flow .time_first );
288297 m_flow_table[flow_index]->is_in_ctt = true ;
289298 }
@@ -355,6 +364,11 @@ bool NHTFlowCache::try_to_export(size_t flow_index, bool call_pre_export, const
355364#ifdef WITH_CTT
356365void NHTFlowCache::send_export_request_to_ctt (size_t ctt_flow_hash) noexcept
357366{
367+ if (m_hashes_in_ctt.find (ctt_flow_hash) == m_hashes_in_ctt.end ())
368+ {
369+ throw " missing hash in send_export_request_to_ctt!" ;
370+ }
371+ m_hashes_in_ctt.erase (ctt_flow_hash);
358372 m_ctt_controller.export_record (ctt_flow_hash);
359373}
360374#endif /* WITH_CTT */
@@ -364,6 +378,9 @@ bool NHTFlowCache::try_to_export(size_t flow_index, bool call_pre_export, const
364378#ifdef WITH_CTT
365379 if (m_flow_table[flow_index]->is_in_ctt ) {
366380 if (!m_flow_table[flow_index]->is_waiting_for_export ) {
381+ if (m_flow_table[flow_index]->m_flow .flow_hash_ctt == 0 ) {
382+ throw " error!" ;
383+ }
367384 m_flow_table[flow_index]->is_waiting_for_export = true ;
368385 send_export_request_to_ctt (m_flow_table[flow_index]->m_flow .flow_hash_ctt );
369386 m_flow_table[flow_index]->export_time = {now.tv_sec + 1 , now.tv_usec };
0 commit comments