Skip to content

Commit 020dc16

Browse files
committed
todo remove debug cache
1 parent 75c7fff commit 020dc16

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

storage/cache.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
356365
void 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};

storage/cache.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <optional>
3939
#include <ipfixprobe/flowifc.hpp>
4040
#include <ipfixprobe/telemetry-utils.hpp>
41-
41+
#include <unordered_set>
4242
#include "fragmentationCache/fragmentationCache.hpp"
4343
#include "cacheOptParser.hpp"
4444
#include "flowKey.tpp"
@@ -122,6 +122,7 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin
122122
std::string m_ctt_device;
123123
unsigned m_ctt_comp_index;
124124
CttController m_ctt_controller;
125+
std::unordered_set<size_t> m_hashes_in_ctt;
125126
#endif /* WITH_CTT */
126127

127128
void try_to_fill_ports_to_fragmented_packet(Packet& packet);

0 commit comments

Comments
 (0)