Skip to content

Commit ff070de

Browse files
committed
Refactor cache
1 parent e5b7a46 commit ff070de

File tree

15 files changed

+890
-773
lines changed

15 files changed

+890
-773
lines changed

Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ ipfixprobe_storage_src=\
7070
storage/fragmentationCache/fragmentationCache.cpp \
7171
storage/cache.cpp \
7272
storage/cache.hpp \
73+
storage/cacheOptParser.hpp \
74+
storage/cacheOptParser.cpp \
75+
storage/flowRecord.hpp \
76+
storage/flowRecord.cpp \
77+
storage/cttController.hpp \
78+
storage/cttController.cpp \
79+
storage/cacheRowSpan.hpp \
80+
storage/cacheRowSpan.cpp \
7381
storage/xxhash.c \
7482
storage/xxhash.h
7583

include/ipfixprobe/packet.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#ifndef IPXP_PACKET_HPP
3333
#define IPXP_PACKET_HPP
34+
//#define WITH_CTT 1 // TODO REMOVE
3435

3536
#include <stdint.h>
3637
#include <stdlib.h>
@@ -46,10 +47,6 @@ namespace ipxp {
4647
* \brief Structure for storing parsed packet fields
4748
*/
4849
struct Packet : public Record {
49-
#ifdef WITH_CTT
50-
Metadata_CTT cttmeta; /**< Metadata from CTT */
51-
bool cttmeta_valid; /**< True if CTT metadata is valid */
52-
#endif /* WITH_CTT */
5350
struct timeval ts;
5451

5552
uint8_t dst_mac[6];
@@ -106,12 +103,16 @@ struct Packet : public Record {
106103
uint16_t buffer_size; /**< Size of buffer */
107104

108105
bool source_pkt; /**< Direction of packet from flow point of view */
106+
#ifdef WITH_CTT
107+
Metadata_CTT cttmeta; /**< Metadata from CTT */
108+
bool cttmeta_valid; /**< True if CTT metadata is valid */
109+
#endif /* WITH_CTT */
109110

110111
/**
111112
* \brief Constructor.
112113
*/
113114
Packet() :
114-
cttmeta_valid(false), ts({0}),
115+
ts({0}),
115116
dst_mac(), src_mac(), ethertype(0),
116117
ip_len(0), ip_payload_len(0), ip_version(0), ip_ttl(0),
117118
ip_proto(0), ip_tos(0), ip_flags(0), src_ip({0}), dst_ip({0}), vlan_id(0),
@@ -123,6 +124,9 @@ struct Packet : public Record {
123124
custom(nullptr), custom_len(0),
124125
buffer(nullptr), buffer_size(0),
125126
source_pkt(true)
127+
#ifdef WITH_CTT
128+
,cttmeta_valid(false)
129+
#endif /* WITH_CTT */
126130
{
127131
}
128132
};

include/ipfixprobe/storage.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ class StoragePlugin : public Plugin
133133

134134
/**
135135
* \brief Checks if process plugins require all available data.
136-
* \param [in] rec Stored flow record.
136+
* \param [in] flow Stored flow record.
137137
* \return True if all data required, false otherwise.
138138
*/
139139
bool all_data_required(const Flow& flow) const noexcept
140140
{
141-
return m_plugins_status.get_all_data.any();
141+
return flow.plugins_status.get_all_data.any();
142142
}
143143

144144
/**
145145
* \brief Checks if process plugins don't require any data.
146-
* \param [in] rec Stored flow record.
146+
* \param [in] flow Stored flow record.
147147
* \return True if no data required, false otherwise.
148148
*/
149149
bool no_data_required(const Flow& flow) const noexcept
150150
{
151-
return m_plugins_status.get_no_data.all();
151+
return flow.plugins_status.get_no_data.all();
152152
}
153153

154154
/**
@@ -190,9 +190,11 @@ class StoragePlugin : public Plugin
190190
int plugins_post_create(Flow& rec, const Packet& pkt)
191191
{
192192
// if metadata are valid, add flow hash ctt to the flow record
193+
#ifdef WITH_CTT
193194
if (pkt.cttmeta_valid) {
194195
rec.flow_hash_ctt = pkt.cttmeta.flow_hash;
195196
}
197+
#endif /* WITH_CTT */
196198
PluginStatusConverter plugin_status_converter(m_plugins_status);
197199
int ret = 0;
198200
for (unsigned int i = 0; i < m_plugin_cnt; i++) {

input/parser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ void parse_packet(parser_opt_t *opt, ParserStats& stats, struct timeval ts, cons
777777
opt->pblock->bytes += len;
778778
}
779779

780+
#ifdef WITH_CTT
780781
int parse_packet_ctt_metadata(parser_opt_t *opt, ParserStats& stats, const Metadata_CTT& metadata, const uint8_t *data, uint16_t len, uint16_t caplen)
781782
{
782783
if (opt->pblock->cnt >= opt->pblock->size) {
@@ -892,5 +893,5 @@ int parse_packet_ctt_metadata(parser_opt_t *opt, ParserStats& stats, const Metad
892893
opt->pblock->bytes += len;
893894
return 0;
894895
}
895-
896+
#endif /* WITH_CTT */
896897
}

0 commit comments

Comments
 (0)