Skip to content

Commit f59f7ea

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce storage CACHE plugin
1 parent 96fc326 commit f59f7ea

File tree

15 files changed

+74
-66
lines changed

15 files changed

+74
-66
lines changed

src/plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_subdirectory(input)
22
add_subdirectory(output)
33
add_subdirectory(process)
4+
add_subdirectory(storage)

src/plugins/storage/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(cache)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
project(ipfixprobe-storage-cache VERSION 1.0.0 DESCRIPTION "ipfixprobe-storage-cache plugin")
2+
3+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
4+
5+
#find_package(xxhash REQUIRED)
6+
7+
add_library(ipfixprobe-storage-cache SHARED
8+
src/cache.hpp
9+
src/cache.cpp
10+
src/fragmentationCache/fragmentationCache.cpp
11+
src/fragmentationCache/fragmentationCache.hpp
12+
src/fragmentationCache/fragmentationKeyData.hpp
13+
src/fragmentationCache/fragmentationTable.cpp
14+
src/fragmentationCache/fragmentationTable.hpp
15+
src/fragmentationCache/ringBuffer.hpp
16+
src/fragmentationCache/timevalUtils.hpp
17+
)
18+
19+
set_target_properties(ipfixprobe-storage-cache PROPERTIES
20+
CXX_VISIBILITY_PRESET hidden
21+
VISIBILITY_INLINES_HIDDEN YES
22+
)
23+
24+
target_include_directories(ipfixprobe-storage-cache PRIVATE ${CMAKE_SOURCE_DIR}/include/)
25+
#target_link_libraries(ipfixprobe-storage-cache PRIVATE xxhash::xxhash)
26+
27+
install(
28+
TARGETS ipfixprobe-storage-cache
29+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/storage/"
30+
)

src/plugins/storage/cache/README.md

Whitespace-only changes.
Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,42 @@
11
/**
2-
* \file cache.cpp
3-
* \brief "NewHashTable" flow cache
4-
* \author Martin Zadnik <[email protected]>
5-
* \author Vaclav Bartos <[email protected]>
6-
* \author Jiri Havranek <[email protected]>
7-
* \date 2014
8-
* \date 2015
9-
* \date 2016
10-
*/
11-
/*
12-
* Copyright (C) 2014-2016 CESNET
13-
*
14-
* LICENSE TERMS
15-
*
16-
* Redistribution and use in source and binary forms, with or without
17-
* modification, are permitted provided that the following conditions
18-
* are met:
19-
* 1. Redistributions of source code must retain the above copyright
20-
* notice, this list of conditions and the following disclaimer.
21-
* 2. Redistributions in binary form must reproduce the above copyright
22-
* notice, this list of conditions and the following disclaimer in
23-
* the documentation and/or other materials provided with the
24-
* distribution.
25-
* 3. Neither the name of the Company nor the names of its contributors
26-
* may be used to endorse or promote products derived from this
27-
* software without specific prior written permission.
28-
*
2+
* @file
3+
* @brief "NewHashTable" flow cache
4+
* @author Martin Zadnik <[email protected]>
5+
* @author Vaclav Bartos <[email protected]>
6+
* @author Jiri Havranek <[email protected]>
7+
* @author Pavel Siska <[email protected]>
8+
* @date 2025
299
*
10+
* Copyright (c) 2025 CESNET
3011
*
12+
* SPDX-License-Identifier: BSD-3-Clause
3113
*/
3214

3315
#include "cache.hpp"
34-
3516
#include "xxhash.h"
3617

3718
#include <cstdlib>
3819
#include <cstring>
3920
#include <iostream>
4021

22+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
23+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
4124
#include <ipfixprobe/ring.h>
4225
#include <sys/time.h>
4326

4427
namespace ipxp {
4528

46-
__attribute__((constructor)) static void register_this_plugin()
47-
{
48-
static PluginRecord rec = PluginRecord("cache", []() { return new NHTFlowCache(); });
49-
register_plugin(&rec);
50-
}
29+
static const PluginManifest cachePluginManifest = {
30+
.name = "cache",
31+
.description = "Storage plugin implemented as a hash table.",
32+
.pluginVersion = "1.0.0",
33+
.apiVersion = "1.0.0",
34+
.usage =
35+
[]() {
36+
CacheOptParser parser;
37+
parser.usage(std::cout);
38+
},
39+
};
5140

5241
FlowRecord::FlowRecord()
5342
{
@@ -161,7 +150,7 @@ void FlowRecord::update(const Packet& pkt, bool src)
161150
}
162151
}
163152

164-
NHTFlowCache::NHTFlowCache()
153+
NHTFlowCache::NHTFlowCache(const std::string& params, ipx_ring_t* queue)
165154
: m_cache_size(0)
166155
, m_line_size(0)
167156
, m_line_mask(0)
@@ -180,6 +169,8 @@ NHTFlowCache::NHTFlowCache()
180169
, m_flow_records(nullptr)
181170
, m_fragmentation_cache(0, 0)
182171
{
172+
set_queue(queue);
173+
init(params.c_str());
183174
}
184175

185176
NHTFlowCache::~NHTFlowCache()
@@ -674,4 +665,8 @@ void NHTFlowCache::prefetch_export_expired() const
674665
__builtin_prefetch(m_flow_table[i], 0, 1);
675666
}
676667
}
668+
669+
static const PluginRegistrar<NHTFlowCache, StoragePluginFactory>
670+
cacheRegistrar(cachePluginManifest);
671+
677672
} // namespace ipxp
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
/**
2-
* \file cache.hpp
3-
* \brief "NewHashTable" flow cache
4-
* \author Martin Zadnik <[email protected]>
5-
* \author Vaclav Bartos <[email protected]>
6-
* \author Jiri Havranek <[email protected]>
7-
* \date 2014
8-
* \date 2015
9-
* \date 2016
10-
*/
11-
/*
12-
* Copyright (C) 2014-2016 CESNET
13-
*
14-
* LICENSE TERMS
15-
*
16-
* Redistribution and use in source and binary forms, with or without
17-
* modification, are permitted provided that the following conditions
18-
* are met:
19-
* 1. Redistributions of source code must retain the above copyright
20-
* notice, this list of conditions and the following disclaimer.
21-
* 2. Redistributions in binary form must reproduce the above copyright
22-
* notice, this list of conditions and the following disclaimer in
23-
* the documentation and/or other materials provided with the
24-
* distribution.
25-
* 3. Neither the name of the Company nor the names of its contributors
26-
* may be used to endorse or promote products derived from this
27-
* software without specific prior written permission.
28-
*
2+
* @file
3+
* @brief "NewHashTable" flow cache
4+
* @author Martin Zadnik <[email protected]>
5+
* @author Vaclav Bartos <[email protected]>
6+
* @author Jiri Havranek <[email protected]>
7+
* @author Pavel Siska <[email protected]>
8+
* @date 2025
299
*
10+
* Copyright (c) 2025 CESNET
3011
*
12+
* SPDX-License-Identifier: BSD-3-Clause
3113
*/
32-
#ifndef IPXP_STORAGE_CACHE_HPP
33-
#define IPXP_STORAGE_CACHE_HPP
14+
15+
#pragma once
3416

3517
#include "fragmentationCache/fragmentationCache.hpp"
3618

3719
#include <string>
3820

3921
#include <ipfixprobe/flowifc.hpp>
4022
#include <ipfixprobe/options.hpp>
41-
#include <ipfixprobe/storage.hpp>
23+
#include <ipfixprobe/storagePlugin.hpp>
4224
#include <ipfixprobe/telemetry-utils.hpp>
4325
#include <ipfixprobe/utils.hpp>
4426

@@ -276,7 +258,7 @@ class NHTFlowCache
276258
: TelemetryUtils
277259
, public StoragePlugin {
278260
public:
279-
NHTFlowCache();
261+
NHTFlowCache(const std::string& params, ipx_ring_t* queue);
280262
~NHTFlowCache();
281263
void init(const char* params);
282264
void close();
@@ -343,4 +325,3 @@ class NHTFlowCache
343325
};
344326

345327
} // namespace ipxp
346-
#endif /* IPXP_STORAGE_CACHE_HPP */

src/plugins/storage/fragmentationCache/fragmentationCache.cpp renamed to src/plugins/storage/cache/src/fragmentationCache/fragmentationCache.cpp

File renamed without changes.

src/plugins/storage/fragmentationCache/fragmentationCache.hpp renamed to src/plugins/storage/cache/src/fragmentationCache/fragmentationCache.hpp

File renamed without changes.

src/plugins/storage/fragmentationCache/fragmentationKeyData.hpp renamed to src/plugins/storage/cache/src/fragmentationCache/fragmentationKeyData.hpp

File renamed without changes.

src/plugins/storage/fragmentationCache/fragmentationTable.cpp renamed to src/plugins/storage/cache/src/fragmentationCache/fragmentationTable.cpp

File renamed without changes.

0 commit comments

Comments
 (0)