Skip to content

Commit

Permalink
Refactor cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Zadamsa committed Dec 21, 2024
1 parent e5b7a46 commit ff070de
Show file tree
Hide file tree
Showing 15 changed files with 890 additions and 773 deletions.
8 changes: 8 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ ipfixprobe_storage_src=\
storage/fragmentationCache/fragmentationCache.cpp \
storage/cache.cpp \
storage/cache.hpp \
storage/cacheOptParser.hpp \
storage/cacheOptParser.cpp \
storage/flowRecord.hpp \
storage/flowRecord.cpp \
storage/cttController.hpp \
storage/cttController.cpp \
storage/cacheRowSpan.hpp \
storage/cacheRowSpan.cpp \
storage/xxhash.c \
storage/xxhash.h

Expand Down
14 changes: 9 additions & 5 deletions include/ipfixprobe/packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#ifndef IPXP_PACKET_HPP
#define IPXP_PACKET_HPP
//#define WITH_CTT 1 // TODO REMOVE

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

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

bool source_pkt; /**< Direction of packet from flow point of view */
#ifdef WITH_CTT
Metadata_CTT cttmeta; /**< Metadata from CTT */
bool cttmeta_valid; /**< True if CTT metadata is valid */
#endif /* WITH_CTT */

/**
* \brief Constructor.
*/
Packet() :
cttmeta_valid(false), ts({0}),
ts({0}),
dst_mac(), src_mac(), ethertype(0),
ip_len(0), ip_payload_len(0), ip_version(0), ip_ttl(0),
ip_proto(0), ip_tos(0), ip_flags(0), src_ip({0}), dst_ip({0}), vlan_id(0),
Expand All @@ -123,6 +124,9 @@ struct Packet : public Record {
custom(nullptr), custom_len(0),
buffer(nullptr), buffer_size(0),
source_pkt(true)
#ifdef WITH_CTT
,cttmeta_valid(false)
#endif /* WITH_CTT */
{
}
};
Expand Down
10 changes: 6 additions & 4 deletions include/ipfixprobe/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,22 @@ class StoragePlugin : public Plugin

/**
* \brief Checks if process plugins require all available data.
* \param [in] rec Stored flow record.
* \param [in] flow Stored flow record.
* \return True if all data required, false otherwise.
*/
bool all_data_required(const Flow& flow) const noexcept
{
return m_plugins_status.get_all_data.any();
return flow.plugins_status.get_all_data.any();
}

/**
* \brief Checks if process plugins don't require any data.
* \param [in] rec Stored flow record.
* \param [in] flow Stored flow record.
* \return True if no data required, false otherwise.
*/
bool no_data_required(const Flow& flow) const noexcept
{
return m_plugins_status.get_no_data.all();
return flow.plugins_status.get_no_data.all();
}

/**
Expand Down Expand Up @@ -190,9 +190,11 @@ class StoragePlugin : public Plugin
int plugins_post_create(Flow& rec, const Packet& pkt)
{
// if metadata are valid, add flow hash ctt to the flow record
#ifdef WITH_CTT
if (pkt.cttmeta_valid) {
rec.flow_hash_ctt = pkt.cttmeta.flow_hash;
}
#endif /* WITH_CTT */
PluginStatusConverter plugin_status_converter(m_plugins_status);
int ret = 0;
for (unsigned int i = 0; i < m_plugin_cnt; i++) {
Expand Down
3 changes: 2 additions & 1 deletion input/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ void parse_packet(parser_opt_t *opt, ParserStats& stats, struct timeval ts, cons
opt->pblock->bytes += len;
}

#ifdef WITH_CTT
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)
{
if (opt->pblock->cnt >= opt->pblock->size) {
Expand Down Expand Up @@ -892,5 +893,5 @@ int parse_packet_ctt_metadata(parser_opt_t *opt, ParserStats& stats, const Metad
opt->pblock->bytes += len;
return 0;
}

#endif /* WITH_CTT */
}
Loading

0 comments on commit ff070de

Please sign in to comment.