Skip to content

Commit

Permalink
ctt controller - add ctt state to flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslavpesek committed Nov 18, 2024
1 parent 5b59c0e commit ca90064
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/ipfixprobe/flowifc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ struct Flow : public Record {
uint64_t flow_hash;
uint64_t flow_hash_ctt; /**< Flow hash for CTT. */
bool ctt_valid; /**< CTT validity flag. */
int ctt_state; /**< CTT - offload or not. */
PluginsStatus plugins_status; /**< Statuses of the process plugins for this flow, used to check
if the flow process plugins requires all available data, only
metadata or nothing of this. */
Expand Down
21 changes: 18 additions & 3 deletions storage/cache-ctt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@ class NHTFlowCacheCTT : public NHTFlowCache
// override post_create method
int plugins_post_create(Flow &rec, Packet &pkt) {
int ret = StoragePlugin::plugins_post_create(rec, pkt);
rec.ctt_state = static_cast<int>(CttController::OffloadMode::NO_OFFLOAD);
if (no_data_required(rec)) {
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
} else if (all_data_required(rec)) {
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
rec.ctt_state = static_cast<int>(CttController::OffloadMode::PACKET_OFFLOAD);
}
return ret;
}


// override post_update method
int plugins_post_update(Flow &rec, Packet &pkt) {
int ret = StoragePlugin::plugins_post_update(rec, pkt);
if (no_data_required(rec) && (rec.ctt_state == static_cast<int>(CttController::OffloadMode::NO_OFFLOAD))) {
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
rec.ctt_state = static_cast<int>(CttController::OffloadMode::PACKET_OFFLOAD);
}
return ret;
}

// override pre_export method
void plugins_pre_export(Flow &rec) {
StoragePlugin::plugins_pre_export(rec);
m_ctt_controller.export_record(rec.flow_hash_ctt);
}


private:
std::string m_dev;
CttController m_ctt_controller;
Expand Down

0 comments on commit ca90064

Please sign in to comment.