From 1053967c244dac6a91fba3a0907a92193abfc571 Mon Sep 17 00:00:00 2001 From: Damir Zainullin Date: Mon, 9 Dec 2024 03:45:04 +0100 Subject: [PATCH] CTT argument parsing - adjust cache opt parser --- storage/cache.cpp | 5 +++-- storage/cache.hpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/storage/cache.cpp b/storage/cache.cpp index af8171c4..6ae54765 100644 --- a/storage/cache.cpp +++ b/storage/cache.cpp @@ -206,7 +206,8 @@ void NHTFlowCache::init(const char *params) m_line_mask = (m_cache_size - 1) & ~(m_line_size - 1); m_line_new_idx = m_line_size / 2; #ifdef WITH_CTT - m_ctt_controller.init(parser.m_dev, 0); + std::cout << "Cache created with device=" << parser.m_dev << " and component index=" << parser.m_component_index << "\n"; + m_ctt_controller.init(parser.m_dev, parser.m_component_index); #endif /* WITH_CTT */ if (m_export_queue == nullptr) { @@ -752,4 +753,4 @@ std::vector CttController::assemble_state( return state; } #endif // WITH_CTT -} \ No newline at end of file +} diff --git a/storage/cache.hpp b/storage/cache.hpp index ad8de024..d03f0d5c 100644 --- a/storage/cache.hpp +++ b/storage/cache.hpp @@ -197,6 +197,7 @@ class CacheOptParser : public OptionsParser time_t m_frag_cache_timeout; #ifdef WITH_CTT std::string m_dev; + uint16_t m_component_index; #endif /* WITH_CTT */ CacheOptParser() : OptionsParser("cache", "Storage plugin implemented as a hash table"), @@ -263,6 +264,14 @@ class CacheOptParser : public OptionsParser return true; }, OptionFlags::RequiredArgument); + register_option("ci", "compidx", "NUM", "Index of the ctt component", [this](const char *arg) { + try { + m_component_index = str2num(arg)/16; + } catch(std::invalid_argument &e) { + return false; + } + return true; + }); #endif /* WITH_CTT */ } @@ -422,4 +431,4 @@ class NHTFlowCache : TelemetryUtils, public StoragePlugin }; } -#endif /* IPXP_STORAGE_CACHE_HPP */ \ No newline at end of file +#endif /* IPXP_STORAGE_CACHE_HPP */