Skip to content

Commit 74761c6

Browse files
authored
Merge pull request #131 from CESNET/active-timeout-overtime-#123
Cache: fixed export of flow with longer duration than active timeout. Fix #123
2 parents 543d41c + ed691b4 commit 74761c6

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

storage/cache.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ int NHTFlowCache::put_pkt(Packet &pkt)
428428
#endif /* FLOW_CACHE_STATS */
429429
}
430430
} else {
431+
/* Check if flow record is expired (inactive timeout). */
431432
if (pkt.ts.tv_sec - flow->m_flow.time_last.tv_sec >= m_inactive) {
432433
m_flow_table[flow_index]->m_flow.end_reason = get_export_reason(flow->m_flow);
433434
plugins_pre_export(flow->m_flow);
@@ -437,6 +438,18 @@ int NHTFlowCache::put_pkt(Packet &pkt)
437438
#endif /* FLOW_CACHE_STATS */
438439
return put_pkt(pkt);
439440
}
441+
442+
/* Check if flow record is expired (active timeout). */
443+
if (pkt.ts.tv_sec - flow->m_flow.time_first.tv_sec >= m_active) {
444+
m_flow_table[flow_index]->m_flow.end_reason = FLOW_END_ACTIVE;
445+
plugins_pre_export(flow->m_flow);
446+
export_flow(flow_index);
447+
#ifdef FLOW_CACHE_STATS
448+
m_expired++;
449+
#endif /* FLOW_CACHE_STATS */
450+
return put_pkt(pkt);
451+
}
452+
440453
ret = plugins_pre_update(flow->m_flow, pkt);
441454
if (ret & FLOW_FLUSH) {
442455
flush(pkt, flow_index, ret, source_flow);
@@ -450,16 +463,6 @@ int NHTFlowCache::put_pkt(Packet &pkt)
450463
return 0;
451464
}
452465
}
453-
454-
/* Check if flow record is expired. */
455-
if (pkt.ts.tv_sec - flow->m_flow.time_first.tv_sec >= m_active) {
456-
m_flow_table[flow_index]->m_flow.end_reason = FLOW_END_ACTIVE;
457-
plugins_pre_export(flow->m_flow);
458-
export_flow(flow_index);
459-
#ifdef FLOW_CACHE_STATS
460-
m_expired++;
461-
#endif /* FLOW_CACHE_STATS */
462-
}
463466
}
464467

465468
export_expired(pkt.ts.tv_sec);

0 commit comments

Comments
 (0)