diff --git a/ipfixprobe.cpp b/ipfixprobe.cpp index 1c4ce6c33..9617c8e98 100644 --- a/ipfixprobe.cpp +++ b/ipfixprobe.cpp @@ -359,6 +359,20 @@ bool process_plugin_args(ipxp_conf_t &conf, IpfixprobeOptParser &parser) throw IPXPError("invalid storage plugin " + storage_name); } storage_plugin->set_queue(output_queue); + #ifdef WITH_CTT + size_t device_start = std::min(input_params.find("dev"), input_params.find("d")); + if (device_start == std::string::npos) { + throw PluginError("device name is not found"); + } + size_t queue_start = input_params.find(":", device_start); + size_t queue_end = input_params.find(";", device_start); + size_t device_end = std::min(queue_end, queue_start); + std::string queue = "0"; + if (queue_start != std::string::npos && queue_start < queue_end) { + queue = input_params.substr(queue_start + 1, queue_end); + } + storage_params += std::string(";ci=") + queue + ";" + input_params.substr(device_start, device_end); + #endif /* WITH_CTT */ storage_plugin->init(storage_params.c_str()); storage_plugin->set_telemetry_dir(pipeline_queue_dir); conf.active.storage.push_back(storage_plugin); diff --git a/storage/cache.cpp b/storage/cache.cpp index af8171c4e..6ae54765c 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 ad8de024e..d03f0d5c2 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 */