Skip to content

Commit ca90064

Browse files
committed
ctt controller - add ctt state to flow
1 parent 5b59c0e commit ca90064

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

include/ipfixprobe/flowifc.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ struct Flow : public Record {
265265
uint64_t flow_hash;
266266
uint64_t flow_hash_ctt; /**< Flow hash for CTT. */
267267
bool ctt_valid; /**< CTT validity flag. */
268+
int ctt_state; /**< CTT - offload or not. */
268269
PluginsStatus plugins_status; /**< Statuses of the process plugins for this flow, used to check
269270
if the flow process plugins requires all available data, only
270271
metadata or nothing of this. */

storage/cache-ctt.hpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,31 @@ class NHTFlowCacheCTT : public NHTFlowCache
3737
// override post_create method
3838
int plugins_post_create(Flow &rec, Packet &pkt) {
3939
int ret = StoragePlugin::plugins_post_create(rec, pkt);
40+
rec.ctt_state = static_cast<int>(CttController::OffloadMode::NO_OFFLOAD);
4041
if (no_data_required(rec)) {
4142
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
42-
} else if (all_data_required(rec)) {
43-
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
43+
rec.ctt_state = static_cast<int>(CttController::OffloadMode::PACKET_OFFLOAD);
4444
}
45+
return ret;
46+
}
4547

46-
48+
// override post_update method
49+
int plugins_post_update(Flow &rec, Packet &pkt) {
50+
int ret = StoragePlugin::plugins_post_update(rec, pkt);
51+
if (no_data_required(rec) && (rec.ctt_state == static_cast<int>(CttController::OffloadMode::NO_OFFLOAD))) {
52+
m_ctt_controller.create_record(rec.flow_hash_ctt, rec.time_first);
53+
rec.ctt_state = static_cast<int>(CttController::OffloadMode::PACKET_OFFLOAD);
54+
}
4755
return ret;
4856
}
4957

58+
// override pre_export method
59+
void plugins_pre_export(Flow &rec) {
60+
StoragePlugin::plugins_pre_export(rec);
61+
m_ctt_controller.export_record(rec.flow_hash_ctt);
62+
}
63+
64+
5065
private:
5166
std::string m_dev;
5267
CttController m_ctt_controller;

0 commit comments

Comments
 (0)