@@ -150,9 +150,11 @@ void FlowRecord::update(const Packet &pkt, bool src)
150150 if (m_flow.is_delayed && !pkt.cttmeta .ctt_rec_matched ) { // it means, the flow is waiting for export and it is not matched in CTT -> it must be new flow
151151 auto flow_hash = m_hash;
152152 m_delayed_flow = m_flow;
153- m_delayed_flow_waiting = true ;
154153 erase (); // erase the old flow, keeping the delayed flow
154+ // Pokud ten update() se vola po pokusu exportovat m_flow kvuli nesotatku mista v radku muze se stat ze flow_hash != XXH64(pkt)
155155 create (pkt, flow_hash);
156+ // Chybi post_create()
157+ m_delayed_flow_waiting = true ;
156158 return ;
157159 }
158160 m_flow.time_last = pkt.ts ;
@@ -272,17 +274,22 @@ void NHTFlowCache::set_queue(ipx_ring_t *queue)
272274
273275void NHTFlowCache::export_flow (size_t index)
274276{
275- if (m_flow_table[index]->m_flow .is_delayed ) {
277+ // Delayed tok by se mel exportovat drive
278+ if (m_flow_table[index]->m_delayed_flow_waiting && !m_flow_table[index]->m_delayed_flow .is_delayed ) {
279+ m_total_exported++;
280+ update_flow_end_reason_stats (m_flow_table[index]->m_delayed_flow .end_reason );
281+ update_flow_record_stats (
282+ m_flow_table[index]->m_delayed_flow .src_packets
283+ + m_flow_table[index]->m_delayed_flow .dst_packets );
284+ ipx_ring_push (m_export_queue, &m_flow_table[index]->m_delayed_flow );
285+ // Ten stary tok smazat
286+ m_flow_table[index]->m_delayed_flow_waiting = false ;
287+ }
288+
289+ if (m_flow_table[index]->m_flow .is_delayed ) {
276290 return ;
277291 }
278- if (m_flow_table[index]->m_delayed_flow_waiting && !m_flow_table[index]->m_delayed_flow .is_delayed ) {
279- m_total_exported++;
280- update_flow_end_reason_stats (m_flow_table[index]->m_delayed_flow .end_reason );
281- update_flow_record_stats (
282- m_flow_table[index]->m_delayed_flow .src_packets
283- + m_flow_table[index]->m_delayed_flow .dst_packets );
284- ipx_ring_push (m_export_queue, &m_flow_table[index]->m_delayed_flow );
285- }
292+
286293 m_total_exported++;
287294 update_flow_end_reason_stats (m_flow_table[index]->m_flow .end_reason );
288295 update_flow_record_stats (
@@ -467,24 +474,29 @@ int NHTFlowCache::put_pkt(Packet &pkt)
467474 }
468475 } else {
469476 /* Check if flow record is expired (inactive timeout). */
470- if (pkt.ts .tv_sec - flow->m_flow .time_last .tv_sec >= m_inactive) {
477+ // Pokud odkomentovat ten kod pod tim je to lepsi ale stale to pada :)
478+ if (pkt.ts .tv_sec - flow->m_flow .time_last .tv_sec >= m_inactive /* && (!flow->m_flow.is_delayed || pkt.ts.tv_sec > flow->m_flow.delay_time) */ ) {
479+ // flow->m_flow.is_delayed = false;
471480 m_flow_table[flow_index]->m_flow .end_reason = get_export_reason (flow->m_flow );
472481 plugins_pre_export (flow->m_flow );
473482 export_flow (flow_index);
474483 #ifdef FLOW_CACHE_STATS
475484 m_expired++;
476485 #endif /* FLOW_CACHE_STATS */
486+ // Pokud m_flow_table[flow_index]->m_flow.is_delayed == true tady je stack overflow
477487 return put_pkt (pkt);
478488 }
479489
480490 /* Check if flow record is expired (active timeout). */
481- if (pkt.ts .tv_sec - flow->m_flow .time_first .tv_sec >= m_active) {
491+ if (pkt.ts .tv_sec - flow->m_flow .time_first .tv_sec >= m_active /* && (!flow->m_flow.is_delayed || pkt.ts.tv_sec > flow->m_flow.delay_time) */ ) {
492+ // flow->m_flow.is_delayed = false;
482493 m_flow_table[flow_index]->m_flow .end_reason = FLOW_END_ACTIVE;
483494 plugins_pre_export (flow->m_flow );
484495 export_flow (flow_index);
485496#ifdef FLOW_CACHE_STATS
486497 m_expired++;
487498#endif /* FLOW_CACHE_STATS */
499+ // Pokud m_flow_table[flow_index]->m_flow.is_delayed == true tady je stack overflow
488500 return put_pkt (pkt);
489501 }
490502
@@ -529,16 +541,18 @@ void NHTFlowCache::export_expired(time_t ts)
529541 m_flow_table[i]->m_flow .end_reason = get_export_reason (m_flow_table[i]->m_flow );
530542 plugins_pre_export (m_flow_table[i]->m_flow );
531543 export_flow (i);
532- if (!m_flow_table[i]->is_empty () && m_flow_table[i]->m_flow .is_delayed && m_flow_table[i]->m_flow .delay_time >= ts) {
533- m_flow_table[i]->m_flow .is_delayed = false ;
534- plugins_pre_export (m_flow_table[i]->m_flow );
535- export_flow (i);
536- }
537- if (!m_flow_table[i]->is_empty () && m_flow_table[i]->m_delayed_flow_waiting && m_flow_table[i]->m_delayed_flow .delay_time >= ts) {
538- m_flow_table[i]->m_delayed_flow_waiting = false ;
539- plugins_pre_export (m_flow_table[i]->m_delayed_flow );
540- export_flow (i);
541- }
544+ // >= vede na to ze pokud jsme vyexportovali tok v 15.999 + 1(delay) = 16.999 >= 16 -> muze se stat ze tok bude exportovan mhohem driv nez za vterinu
545+ if (!m_flow_table[i]->is_empty () && m_flow_table[i]->m_flow .is_delayed && m_flow_table[i]->m_flow .delay_time > ts) {
546+ m_flow_table[i]->m_flow .is_delayed = false ;
547+ plugins_pre_export (m_flow_table[i]->m_flow );
548+ export_flow (i);
549+ }
550+ // to same tady
551+ if (!m_flow_table[i]->is_empty () && m_flow_table[i]->m_delayed_flow_waiting && m_flow_table[i]->m_delayed_flow .delay_time > ts) {
552+ m_flow_table[i]->m_delayed_flow_waiting = false ;
553+ plugins_pre_export (m_flow_table[i]->m_delayed_flow );
554+ export_flow (i);
555+ }
542556#ifdef FLOW_CACHE_STATS
543557 m_expired++;
544558#endif /* FLOW_CACHE_STATS */
0 commit comments