suricata
flow-worker.c
Go to the documentation of this file.
1 /* Copyright (C) 2016-2024 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  * Flow Workers are single thread modules taking care of (almost)
24  * everything related to packets with flows:
25  *
26  * - Lookup/creation
27  * - Stream tracking, reassembly
28  * - Applayer update
29  * - Detection
30  *
31  * This all while holding the flow lock.
32  */
33 
34 #include "suricata-common.h"
35 #include "suricata.h"
36 
37 #include "action-globals.h"
38 #include "packet.h"
39 #include "decode.h"
40 #include "detect.h"
41 #include "stream-tcp.h"
42 #include "app-layer.h"
43 #include "detect-engine.h"
44 #include "output.h"
45 #include "app-layer-parser.h"
46 #include "app-layer-frames.h"
47 
48 #include "util-profiling.h"
49 #include "util-validate.h"
50 #include "tmqh-packetpool.h"
51 
52 #include "flow-util.h"
53 #include "flow-manager.h"
54 #include "flow-timeout.h"
55 #include "flow-spare-pool.h"
56 #include "flow-worker.h"
57 
59 
60 typedef struct FlowTimeoutCounters {
64 
65 typedef struct FlowWorkerThreadData_ {
67 
68  union {
71  };
72 
74 
75  void *output_thread; /* Output thread data. */
76  void *output_thread_flow; /* Output thread data. */
77 
82  /** Queue to put pseudo packets that have been created by the stream (RST response) and by the
83  * flush logic following a protocol change. */
86 
87  struct {
93  } cnt;
95 
97 
98 static void FlowWorkerFlowTimeout(
100 
101 /**
102  * \internal
103  * \brief Forces reassembly for flow if it needs it.
104  *
105  * The function requires flow to be locked beforehand.
106  *
107  * \param f Pointer to the flow.
108  *
109  * \retval cnt number of packets injected
110  */
111 static int FlowFinish(ThreadVars *tv, Flow *f, FlowWorkerThreadData *fw, void *detect_thread)
112 {
113  const int server = f->ffr_tc;
114  const int client = f->ffr_ts;
115  int cnt = 0;
116 
117  /* Get the tcp session for the flow */
118  const TcpSession *ssn = (TcpSession *)f->protoctx;
119 
120  /* insert a pseudo packet in the toserver direction */
122  Packet *p = FlowPseudoPacketGet(0, f, ssn);
123  if (p != NULL) {
125  if (server == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE) {
127  }
128  FlowWorkerFlowTimeout(tv, p, fw, detect_thread);
130  cnt++;
131  }
132  }
133 
134  /* handle toclient */
136  Packet *p = FlowPseudoPacketGet(1, f, ssn);
137  if (p != NULL) {
140  FlowWorkerFlowTimeout(tv, p, fw, detect_thread);
143  cnt++;
144  }
145  }
146 
147  if (cnt > 0) {
149  }
150  return cnt;
151 }
152 
153 /** \param[in] max_work Max flows to process. 0 if unlimited. */
154 static void CheckWorkQueue(ThreadVars *tv, FlowWorkerThreadData *fw, FlowTimeoutCounters *counters,
155  FlowQueuePrivate *fq, const uint32_t max_work)
156 {
157  FlowQueuePrivate ret_queue = { NULL, NULL, 0 };
158  uint32_t i = 0;
159  Flow *f;
160  while ((f = FlowQueuePrivateGetFromTop(fq)) != NULL) {
162  f->flow_end_flags |= FLOW_END_FLAG_TIMEOUT; //TODO emerg
163 
164  if (f->proto == IPPROTO_TCP) {
165  /* an IDS drop does not end the app layer, so keep the final flush */
166  const bool drop_ends = (f->flags & FLOW_ACTION_DROP) != 0 && EngineModeIsIPS();
167  if (!(f->flags & FLOW_TIMEOUT_REASSEMBLY_DONE) && !drop_ends && !FlowIsBypassed(f) &&
168  FlowNeedsReassembly(f) && f->ffr != 0) {
169  /* read detect thread in case we're doing a reload */
170  void *detect_thread = SC_ATOMIC_GET(fw->detect_thread);
171  int cnt = FlowFinish(tv, f, fw, detect_thread);
172  counters->flows_aside_pkt_inject += cnt;
173  counters->flows_aside_needs_work++;
174  }
175  }
176 
177  /* no one is referring to this flow, removed from hash
178  * so we can unlock it and pass it to the flow recycler */
179 
180  if (fw->output_thread_flow != NULL)
181  (void)OutputFlowLog(tv, fw->output_thread_flow, f);
182 
183  FlowEndCountersUpdate(tv, &fw->fec, f);
184  if (f->proto == IPPROTO_TCP && f->protoctx != NULL) {
186  }
188 
191 
192  if (fw->fls.spare_queue.len >= (FLOW_SPARE_POOL_BLOCK_SIZE * 2)) {
193  FlowQueuePrivatePrependFlow(&ret_queue, f);
194  if (ret_queue.len == FLOW_SPARE_POOL_BLOCK_SIZE) {
195  FlowSparePoolReturnFlows(&ret_queue);
196  }
197  } else {
199  }
200 
201  if (max_work != 0 && ++i == max_work)
202  break;
203  }
204  if (ret_queue.len > 0) {
205  FlowSparePoolReturnFlows(&ret_queue);
206  }
207 
208  StatsCounterAddI64(&tv->stats, fw->cnt.flows_removed, (int64_t)i);
209 }
210 
211 /** \brief handle flow for packet
212  *
213  * Handle flow creation/lookup
214  */
215 static inline TmEcode FlowUpdate(ThreadVars *tv, FlowWorkerThreadData *fw, Packet *p)
216 {
217  FlowHandlePacketUpdate(p->flow, p, tv, fw->dtv);
218 
219  int state = p->flow->flow_state;
220  switch (state) {
221 #ifdef CAPTURE_OFFLOAD
222  case FLOW_STATE_CAPTURE_BYPASSED: {
225  Flow *f = p->flow;
226  FlowDeReference(&p->flow);
228  return TM_ECODE_DONE;
229  }
230 #endif
234  Flow *f = p->flow;
235  FlowDeReference(&p->flow);
237  return TM_ECODE_DONE;
238  }
239  default:
240  return TM_ECODE_OK;
241  }
242 }
243 
244 static TmEcode FlowWorkerThreadDeinit(ThreadVars *tv, void *data);
245 
246 static TmEcode FlowWorkerThreadInit(ThreadVars *tv, const void *initdata, void **data)
247 {
248  FlowWorkerThreadData *fw = SCCalloc(1, sizeof(*fw));
249  if (fw == NULL)
250  return TM_ECODE_FAILED;
251 
252  SC_ATOMIC_INITPTR(fw->detect_thread);
253  SC_ATOMIC_SET(fw->detect_thread, NULL);
254 
255  fw->local_bypass_pkts = StatsRegisterCounter("flow_bypassed.local_pkts", &tv->stats);
256  fw->local_bypass_bytes = StatsRegisterCounter("flow_bypassed.local_bytes", &tv->stats);
257  fw->both_bypass_pkts = StatsRegisterCounter("flow_bypassed.local_capture_pkts", &tv->stats);
258  fw->both_bypass_bytes = StatsRegisterCounter("flow_bypassed.local_capture_bytes", &tv->stats);
259 
261  StatsRegisterCounter("flow.wrk.flows_evicted_needs_work", &tv->stats);
263  StatsRegisterCounter("flow.wrk.flows_evicted_pkt_inject", &tv->stats);
264  fw->cnt.flows_removed = StatsRegisterCounter("flow.wrk.flows_evicted", &tv->stats);
265  fw->cnt.flows_injected = StatsRegisterCounter("flow.wrk.flows_injected", &tv->stats);
266  fw->cnt.flows_injected_max = StatsRegisterMaxCounter("flow.wrk.flows_injected_max", &tv->stats);
267 
268  fw->fls.dtv = fw->dtv = DecodeThreadVarsAlloc(tv);
269  if (fw->dtv == NULL) {
270  FlowWorkerThreadDeinit(tv, fw);
271  return TM_ECODE_FAILED;
272  }
273 
274  /* setup TCP */
275  if (StreamTcpThreadInit(tv, NULL, &fw->stream_thread_ptr) != TM_ECODE_OK) {
276  FlowWorkerThreadDeinit(tv, fw);
277  return TM_ECODE_FAILED;
278  }
279 
280  if (DetectEngineEnabled()) {
281  /* setup DETECT */
282  void *detect_thread = NULL;
283  if (DetectEngineThreadCtxInit(tv, NULL, &detect_thread) != TM_ECODE_OK) {
284  FlowWorkerThreadDeinit(tv, fw);
285  return TM_ECODE_FAILED;
286  }
287  SC_ATOMIC_SET(fw->detect_thread, detect_thread);
288  }
289 
290  /* Setup outputs for this thread. */
291  if (OutputLoggerThreadInit(tv, initdata, &fw->output_thread) != TM_ECODE_OK) {
292  FlowWorkerThreadDeinit(tv, fw);
293  return TM_ECODE_FAILED;
294  }
296  SCLogError("initializing flow log API for thread failed");
297  FlowWorkerThreadDeinit(tv, fw);
298  return TM_ECODE_FAILED;
299  }
300 
304 
305  /* setup pq for stream end pkts */
306  memset(&fw->pq, 0, sizeof(PacketQueueNoLock));
307  *data = fw;
308  return TM_ECODE_OK;
309 }
310 
311 static TmEcode FlowWorkerThreadDeinit(ThreadVars *tv, void *data)
312 {
313  FlowWorkerThreadData *fw = data;
314 
316 
317  /* free TCP */
318  StreamTcpThreadDeinit(tv, (void *)fw->stream_thread);
319 
320  /* free DETECT */
321  void *detect_thread = SC_ATOMIC_GET(fw->detect_thread);
322  if (detect_thread != NULL) {
323  DetectEngineThreadCtxDeinit(tv, detect_thread);
324  SC_ATOMIC_SET(fw->detect_thread, NULL);
325  }
326 
327  /* Free output. */
330 
331  /* free pq */
332  BUG_ON(fw->pq.len);
333 
334  Flow *f;
335  while ((f = FlowQueuePrivateGetFromTop(&fw->fls.spare_queue)) != NULL) {
336  FlowFree(f);
337  }
338 
339  SCFree(fw);
340  return TM_ECODE_OK;
341 }
342 
343 TmEcode Detect(ThreadVars *tv, Packet *p, void *data);
345 
346 static inline void UpdateCounters(ThreadVars *tv,
347  FlowWorkerThreadData *fw, const FlowTimeoutCounters *counters)
348 {
349  if (counters->flows_aside_needs_work) {
351  (int64_t)counters->flows_aside_needs_work);
352  }
353  if (counters->flows_aside_pkt_inject) {
355  (int64_t)counters->flows_aside_pkt_inject);
356  }
357 }
358 
359 /** \brief update stream engine
360  *
361  * We can be called from both the flow timeout path as well as from the
362  * "real" traffic path. If in the timeout path any additional packets we
363  * forge for flushing pipelines should not leave our scope. If the original
364  * packet is real (or related to a real packet) we need to push the packets
365  * on, so IPS logic stays valid.
366  */
367 static inline void FlowWorkerStreamTCPUpdate(ThreadVars *tv, FlowWorkerThreadData *fw, Packet *p,
368  DetectEngineThreadCtx *det_ctx, const bool timeout)
369 {
370  if (det_ctx != NULL && det_ctx->de_ctx->PreStreamHook != NULL) {
371  const uint8_t action = det_ctx->de_ctx->PreStreamHook(tv, det_ctx, p);
372  if (action & ACTION_DROP) {
374  return;
375  }
376  }
377 
379  StreamTcp(tv, p, fw->stream_thread, &fw->pq);
381 
382  // this is the first packet that sets no payload inspection
383  bool setting_nopayload =
384  p->flow->alparser &&
385  SCAppLayerParserStateIssetFlag(p->flow->alparser, APP_LAYER_PARSER_NO_INSPECTION) &&
387  if (FlowChangeProto(p->flow) || setting_nopayload) {
389  if (setting_nopayload) {
390  FlowSetNoPayloadInspectionFlag(p->flow);
391  }
392  SCAppLayerParserStateSetFlag(p->flow->alparser, APP_LAYER_PARSER_EOF_TS);
393  SCAppLayerParserStateSetFlag(p->flow->alparser, APP_LAYER_PARSER_EOF_TC);
394  }
395 
396  /* Packets here can safely access p->flow as it's locked */
397  SCLogDebug("packet %" PRIu64 ": extra packets %u", PcapPacketCntGet(p), fw->pq.len);
398  Packet *x;
399  while ((x = PacketDequeueNoLock(&fw->pq))) {
400  SCLogDebug("packet %" PRIu64 " extra packet %p", PcapPacketCntGet(p), x);
401 
402  if (det_ctx != NULL) {
404  Detect(tv, x, det_ctx);
406  }
407 
409 
410  FramesPrune(x->flow, x);
411  /* Release tcp segments. Done here after alerting can use them. */
414  x->flow, x->flowflags & FLOW_PKT_TOSERVER ? STREAM_TOSERVER : STREAM_TOCLIENT);
416 
417  /* no need to keep a flow ref beyond this point */
418  FlowDeReference(&x->flow);
419 
420  /* no further work to do for this pseudo packet, so we can return
421  * it to the pool immediately. */
422  if (timeout) {
424  } else {
425  /* to support IPS verdict logic, in the non-timeout case we need to do a bit more */
427  }
428  }
430  // in case f->flags & FLOW_ACTION_DROP was set by one of the dequeued packets
433  } else {
435  }
436  }
437 }
438 
439 static void FlowWorkerFlowTimeout(
441 {
443 
444  SCLogDebug("packet %" PRIu64 " is TCP. Direction %s", PcapPacketCntGet(p),
445  PKT_IS_TOSERVER(p) ? "TOSERVER" : "TOCLIENT");
446  DEBUG_VALIDATE_BUG_ON(!(p->flow && PacketIsTCP(p)));
448 
449  /* handle TCP and app layer */
450  FlowWorkerStreamTCPUpdate(tv, fw, p, det_ctx, true);
451 
453 
454  /* handle Detect */
455  SCLogDebug("packet %" PRIu64 " calling Detect", PcapPacketCntGet(p));
456  if (det_ctx != NULL) {
458  Detect(tv, p, det_ctx);
460  }
461 
462  // Outputs.
464 
465  FramesPrune(p->flow, p);
466 
467  /* Release tcp segments. Done here after alerting can use them. */
470  STREAM_TOSERVER : STREAM_TOCLIENT);
472 
473  /* run tx cleanup last */
475 
476  FlowDeReference(&p->flow);
477  /* flow is unlocked later in FlowFinish() */
478 }
479 
480 /** \internal
481  * \brief process flows injected into our queue by other threads
482  */
483 static inline void FlowWorkerProcessInjectedFlows(
485 {
486  /* take injected flows and append to our work queue */
488  FlowQueuePrivate injected = { NULL, NULL, 0 };
489  if (SC_ATOMIC_GET(tv->flow_queue->non_empty))
491  if (injected.len > 0) {
492  StatsCounterAddI64(&tv->stats, fw->cnt.flows_injected, (int64_t)injected.len);
493  if (p->pkt_src == PKT_SRC_WIRE)
494  StatsCounterMaxUpdateI64(&tv->stats, fw->cnt.flows_injected_max, (int64_t)injected.len);
495 
496  /* move to local queue so we can process over the course of multiple packets */
498  }
500 }
501 
502 /** \internal
503  * \brief process flows set aside locally during flow lookup
504  */
505 static inline void FlowWorkerProcessLocalFlows(ThreadVars *tv, FlowWorkerThreadData *fw, Packet *p)
506 {
507  uint32_t max_work = 2;
509  max_work = 0;
510 
512  if (fw->fls.work_queue.len) {
513  FlowTimeoutCounters counters = { 0, 0, };
514  CheckWorkQueue(tv, fw, &counters, &fw->fls.work_queue, max_work);
515  UpdateCounters(tv, fw, &counters);
516  }
518 }
519 
520 /** \internal
521  * \brief apply Packet::app_update_direction to the flow flags
522  */
523 static void PacketAppUpdate2FlowFlags(Packet *p)
524 {
525  switch ((enum StreamUpdateDir)p->app_update_direction) {
526  case UPDATE_DIR_NONE: // NONE implies pseudo packet
527  SCLogDebug("pcap_cnt %" PRIu64 ", UPDATE_DIR_NONE", PcapPacketCntGet(p));
528  break;
529  case UPDATE_DIR_PACKET:
530  if (PKT_IS_TOSERVER(p)) {
532  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TS_APP_UPDATED set", PcapPacketCntGet(p));
533  } else {
535  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TC_APP_UPDATED set", PcapPacketCntGet(p));
536  }
537  break;
538  case UPDATE_DIR_BOTH:
539  if (PKT_IS_TOSERVER(p)) {
541  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TS_APP_UPDATED|FLOW_TC_APP_UPDATE_NEXT set",
543  } else {
545  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TC_APP_UPDATED|FLOW_TS_APP_UPDATE_NEXT set",
547  }
548  /* fall through */
549  case UPDATE_DIR_OPPOSING:
550  if (PKT_IS_TOSERVER(p)) {
552  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TC_APP_UPDATED|FLOW_TS_APP_UPDATE_NEXT set",
554  } else {
556  SCLogDebug("pcap_cnt %" PRIu64 ", FLOW_TS_APP_UPDATED|FLOW_TC_APP_UPDATE_NEXT set",
558  }
559  break;
560  }
561 }
562 
563 static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data)
564 {
565  FlowWorkerThreadData *fw = data;
566  DetectEngineThreadCtx *det_ctx = SC_ATOMIC_GET(fw->detect_thread);
567 
568  DEBUG_VALIDATE_BUG_ON(p == NULL);
570 
571  SCLogDebug("packet %" PRIu64, PcapPacketCntGet(p));
572 
573  /* handle Flow */
574  if (det_ctx != NULL && det_ctx->de_ctx->PreFlowHook != NULL) {
575  const uint8_t action = det_ctx->de_ctx->PreFlowHook(tv, det_ctx, p);
576  if (action & ACTION_DROP) {
578  goto pre_flow_drop;
579  }
580  }
581 
582  if (p->flags & PKT_WANTS_FLOW) {
584 
585  FlowHandlePacket(tv, &fw->fls, p);
586  if (likely(p->flow != NULL)) {
588  if (FlowUpdate(tv, fw, p) == TM_ECODE_DONE) {
589  /* update time */
590  if (!(PKT_IS_PSEUDOPKT(p))) {
591  TimeSetByThread(tv->id, p->ts);
592  }
593  goto housekeeping;
594  }
595  }
596  /* Flow is now LOCKED */
597 
599 
600  /* if PKT_WANTS_FLOW is not set, but PKT_HAS_FLOW is, then this is a
601  * pseudo packet created by the flow manager. */
602  } else if (p->flags & PKT_HAS_FLOW) {
605  }
606 
607  /* update time */
608  if (!(PKT_IS_PSEUDOPKT(p))) {
609  TimeSetByThread(tv->id, p->ts);
610  }
611 
612  SCLogDebug("packet %" PRIu64 " has flow? %s", PcapPacketCntGet(p), p->flow ? "yes" : "no");
613 
614  /* handle TCP and app layer */
615  if (p->flow) {
616  SCLogDebug("packet %" PRIu64
617  ": direction %s FLOW_TS_APP_UPDATE_NEXT %s FLOW_TC_APP_UPDATE_NEXT %s",
618  PcapPacketCntGet(p), PKT_IS_TOSERVER(p) ? "toserver" : "toclient",
621  /* see if need to consider flags set by prev packets */
625  SCLogDebug("FLOW_TS_APP_UPDATED");
626  } else if (PKT_IS_TOCLIENT(p) && (p->flow->flags & FLOW_TC_APP_UPDATE_NEXT)) {
629  SCLogDebug("FLOW_TC_APP_UPDATED");
630  }
631 
632  if (PacketIsTCP(p)) {
633  SCLogDebug("packet %" PRIu64 " is TCP. Direction %s", PcapPacketCntGet(p),
634  PKT_IS_TOSERVER(p) ? "TOSERVER" : "TOCLIENT");
636 
637  /* if detect is disabled, we need to apply file flags to the flow
638  * here on the first packet. */
639  if (det_ctx == NULL &&
643  }
644 
645  FlowWorkerStreamTCPUpdate(tv, fw, p, det_ctx, false);
646  PacketAppUpdate2FlowFlags(p);
647 
648  /* handle the app layer part of the UDP packet payload */
649  } else if (p->proto == IPPROTO_UDP && !PacketCheckAction(p, ACTION_DROP)) {
653  PacketAppUpdate2FlowFlags(p);
654  }
655  }
656 
658 
659  /* handle Detect */
661  SCLogDebug("packet %" PRIu64 " calling Detect", PcapPacketCntGet(p));
662  if (det_ctx != NULL) {
664  Detect(tv, p, det_ctx);
666  }
667 
668 pre_flow_drop:
669  // Outputs.
671 
672  /* Release tcp segments. Done here after alerting can use them. */
673  if (p->flow != NULL) {
675 
676  if (FlowIsBypassed(p->flow)) {
677  /* the tx loggers already ran for a pending flush (OutputLoggerLog
678  * above): clear the flag and free the app layer */
681  if (p->proto == IPPROTO_TCP) {
683  }
684  } else if (p->proto == IPPROTO_TCP && p->flow->protoctx && p->flags & PKT_STREAM_EST) {
686  FramesPrune(p->flow, p);
687  } else if ((p->flow->flags & FLOW_TC_APP_UPDATED) && PKT_IS_TOCLIENT(p)) {
688  FramesPrune(p->flow, p);
689  }
692  STREAM_TOSERVER : STREAM_TOCLIENT);
694  } else if (p->proto == IPPROTO_UDP) {
695  FramesPrune(p->flow, p);
696  }
697 
698  if ((PKT_IS_PSEUDOPKT(p)) ||
700  if ((p->flags & PKT_STREAM_EST) || p->proto != IPPROTO_TCP) {
701  if (PKT_IS_TOSERVER(p)) {
702  if (PKT_IS_PSEUDOPKT(p) || (p->flow->flags & (FLOW_TS_APP_UPDATED))) {
703  AppLayerParserTransactionsCleanup(p->flow, STREAM_TOSERVER);
705  SCLogDebug("~FLOW_TS_APP_UPDATED");
706  }
707  } else {
708  if (PKT_IS_PSEUDOPKT(p) || (p->flow->flags & (FLOW_TC_APP_UPDATED))) {
709  AppLayerParserTransactionsCleanup(p->flow, STREAM_TOCLIENT);
711  SCLogDebug("~FLOW_TC_APP_UPDATED");
712  }
713  }
714  }
715  } else {
716  SCLogDebug("not pseudo, no app update: skip");
717  }
718 
719  if (p->flow->flags & FLOW_ACTION_DROP) {
720  SCLogDebug("flow drop in place: remove app update flags");
722  }
723 
724  Flow *f = p->flow;
725  FlowDeReference(&p->flow);
727  }
728 
729 housekeeping:
730 
731  /* take injected flows and add them to our local queue */
732  FlowWorkerProcessInjectedFlows(tv, fw, p);
733 
734  /* process local work queue */
735  FlowWorkerProcessLocalFlows(tv, fw, p);
736 
737  return TM_ECODE_OK;
738 }
739 
740 void FlowWorkerReplaceDetectCtx(void *flow_worker, void *detect_ctx)
741 {
742  FlowWorkerThreadData *fw = flow_worker;
743 
744  SC_ATOMIC_SET(fw->detect_thread, detect_ctx);
745 }
746 
747 void *FlowWorkerGetDetectCtxPtr(void *flow_worker)
748 {
749  FlowWorkerThreadData *fw = flow_worker;
750 
751  return SC_ATOMIC_GET(fw->detect_thread);
752 }
753 
754 void *FlowWorkerGetThreadData(void *flow_worker)
755 {
756  return (FlowWorkerThreadData *)flow_worker;
757 }
758 
760 {
761  switch (fwi) {
763  return "flow";
765  return "stream";
767  return "app-layer";
769  return "detect";
771  return "tcp-prune";
773  return "flow-inject";
775  return "flow-evict";
777  return "size";
778  }
779  return "error";
780 }
781 
782 static bool FlowWorkerIsBusy(ThreadVars *tv, void *flow_worker)
783 {
784  FlowWorkerThreadData *fw = flow_worker;
785  if (fw->pq.len)
786  return true;
787  if (fw->fls.work_queue.len)
788  return true;
789 
790  if (tv->flow_queue) {
792  bool fq_done = (tv->flow_queue->qlen == 0);
794  if (!fq_done) {
795  return true;
796  }
797  }
798 
799  return false;
800 }
801 
803 {
804  tmm_modules[TMM_FLOWWORKER].name = "FlowWorker";
805  tmm_modules[TMM_FLOWWORKER].ThreadInit = FlowWorkerThreadInit;
806  tmm_modules[TMM_FLOWWORKER].Func = FlowWorker;
807  tmm_modules[TMM_FLOWWORKER].ThreadBusy = FlowWorkerIsBusy;
808  tmm_modules[TMM_FLOWWORKER].ThreadDeinit = FlowWorkerThreadDeinit;
811 }
PKT_IS_TOCLIENT
#define PKT_IS_TOCLIENT(p)
Definition: decode.h:240
TmModule_::cap_flags
uint8_t cap_flags
Definition: tm-modules.h:77
PacketCheckAction
bool PacketCheckAction(const Packet *p, const uint8_t a)
Definition: packet.c:50
UPDATE_DIR_BOTH
@ UPDATE_DIR_BOTH
Definition: stream-tcp-reassemble.h:58
Flow_::ffr_tc
uint8_t ffr_tc
Definition: flow.h:391
FlowLookupStruct_::work_queue
FlowQueuePrivate work_queue
Definition: flow.h:551
UPDATE_DIR_PACKET
@ UPDATE_DIR_PACKET
Definition: stream-tcp-reassemble.h:56
ThreadVars_::flow_queue
struct FlowQueue_ * flow_queue
Definition: threadvars.h:130
OutputFlowLog
TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f)
Run flow logger(s)
Definition: output-flow.c:87
FLOW_TC_APP_UPDATE_NEXT
#define FLOW_TC_APP_UPDATE_NEXT
Definition: flow.h:56
Packet_::proto
uint8_t proto
Definition: decode.h:538
StatsCounterMaxUpdateI64
void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId id, int64_t x)
update the value of the localmax counter
Definition: counters.c:222
SCAppLayerParserStateIssetFlag
uint16_t SCAppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
Definition: app-layer-parser.c:2079
FLOW_ACTION_BY_FIREWALL
#define FLOW_ACTION_BY_FIREWALL
Definition: flow.h:125
FlowCleanupAppLayer
void FlowCleanupAppLayer(Flow *f)
Definition: flow.c:137
FlowTimeoutCounters
Definition: flow-worker.c:60
detect-engine.h
Flow_::ffr_ts
uint8_t ffr_ts
Definition: flow.h:390
PROFILE_FLOWWORKER_DETECT
@ PROFILE_FLOWWORKER_DETECT
Definition: flow-worker.h:25
OutputFlowLogThreadInit
TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data)
thread init for the flow logger This will run the thread init functions for the individual registered...
Definition: output-flow.c:121
Flow_::flags
uint64_t flags
Definition: flow.h:408
PKT_HAS_FLOW
#define PKT_HAS_FLOW
Definition: decode.h:1311
PKT_DROP_REASON_FW_FLOW_DROP
@ PKT_DROP_REASON_FW_FLOW_DROP
Definition: decode.h:412
PROFILE_FLOWWORKER_FLOW_INJECTED
@ PROFILE_FLOWWORKER_FLOW_INJECTED
Definition: flow-worker.h:27
flow-util.h
FlowWorkerThreadData
struct FlowWorkerThreadData_ FlowWorkerThreadData
FlowLookupStruct_::dtv
DecodeThreadVars * dtv
Definition: flow.h:550
PKT_IS_PSEUDOPKT
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
Definition: decode.h:1364
stream-tcp.h
PacketPoolReturnPacket
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
Definition: tmqh-packetpool.c:168
FLOW_PKT_LAST_PSEUDO
#define FLOW_PKT_LAST_PSEUDO
Definition: flow.h:243
SC_ATOMIC_SET
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
Definition: util-atomic.h:386
AppLayerParserTransactionsCleanup
void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
remove obsolete (inspected and logged) transactions
Definition: app-layer-parser.c:993
PROFILE_FLOWWORKER_FLOW_EVICTED
@ PROFILE_FLOWWORKER_FLOW_EVICTED
Definition: flow-worker.h:28
ProfileFlowWorkerIdToString
const char * ProfileFlowWorkerIdToString(enum ProfileFlowWorkerId fwi)
Definition: flow-worker.c:759
DetectEngineCtx_::PreFlowHook
DetectPacketHookFunc PreFlowHook
Definition: detect.h:1228
PcapPacketCntGet
uint64_t PcapPacketCntGet(const Packet *p)
Definition: decode.c:1193
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
PKT_SRC_SHUTDOWN_FLUSH
@ PKT_SRC_SHUTDOWN_FLUSH
Definition: decode.h:64
StatsRegisterCounter
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
Definition: counters.c:1038
StreamTcpThread_
Definition: stream-tcp.h:92
PROFILE_FLOWWORKER_TCPPRUNE
@ PROFILE_FLOWWORKER_TCPPRUNE
Definition: flow-worker.h:26
Flow_::proto
uint8_t proto
Definition: flow.h:381
TM_ECODE_DONE
@ TM_ECODE_DONE
Definition: tm-threads-common.h:83
PKT_SRC_CAPTURE_TIMEOUT
@ PKT_SRC_CAPTURE_TIMEOUT
Definition: decode.h:62
action-globals.h
TcpReassemblyThreadCtx_::app_tctx
void * app_tctx
Definition: stream-tcp-reassemble.h:62
Packet_::flags
uint32_t flags
Definition: decode.h:562
DetectEngineCtx_::PreStreamHook
DetectPacketHookFunc PreStreamHook
Definition: detect.h:1223
SCAppLayerParserStateSetFlag
void SCAppLayerParserStateSetFlag(AppLayerParserState *pstate, uint16_t flag)
Definition: app-layer-parser.c:2071
ssn
TcpSession ssn
Definition: fuzz_dataset.c:31
Flow_
Flow data structure.
Definition: flow.h:359
Flow_::protomap
uint8_t protomap
Definition: flow.h:450
FLOW_TC_APP_UPDATED
#define FLOW_TC_APP_UPDATED
Definition: flow.h:119
PKT_WANTS_FLOW
#define PKT_WANTS_FLOW
Definition: decode.h:1341
FlowTimeoutCounters::flows_aside_pkt_inject
uint32_t flows_aside_pkt_inject
Definition: flow-worker.c:62
AppLayerRegisterThreadCounters
void AppLayerRegisterThreadCounters(ThreadVars *tv)
Registers per flow counters for all protocols.
Definition: app-layer.c:1325
FlowLookupStruct_
Definition: flow.h:547
FlowWorkerThreadData_::local_bypass_pkts
StatsCounterId local_bypass_pkts
Definition: flow-worker.c:78
FlowWorkerThreadData_::dtv
DecodeThreadVars * dtv
Definition: flow-worker.c:66
StreamTcpThreadInit
TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data)
Definition: stream-tcp.c:6178
FLOW_PKT_TOSERVER
#define FLOW_PKT_TOSERVER
Definition: flow.h:236
FlowPseudoPacketGet
Packet * FlowPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
Definition: flow-timeout.c:264
FLOW_APP_LAYER_FLUSH_PENDING
#define FLOW_APP_LAYER_FLUSH_PENDING
Definition: flow.h:132
FlowHandlePacket
void FlowHandlePacket(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
Entry point for packet flow handling.
Definition: flow.c:560
FLOW_ACTION_DROP
#define FLOW_ACTION_DROP
Definition: flow.h:69
p
Packet * p
Definition: fuzz_dataset.c:30
StatsCounterId
Definition: counters.h:30
FlowQueuePrivatePrependFlow
void FlowQueuePrivatePrependFlow(FlowQueuePrivate *fqc, Flow *f)
Definition: flow-queue.c:78
PKT_NOPAYLOAD_INSPECTION
#define PKT_NOPAYLOAD_INSPECTION
Definition: decode.h:1297
FlowWorkerThreadData_::stream_thread
StreamTcpThread * stream_thread
Definition: flow-worker.c:69
TmModule_::ThreadBusy
bool(* ThreadBusy)(ThreadVars *tv, void *thread_data)
Definition: tm-modules.h:67
FlowWorkerThreadData_::flows_removed
StatsCounterId flows_removed
Definition: flow-worker.c:90
Packet_::flowflags
uint8_t flowflags
Definition: decode.h:547
TmqhOutputPacketpool
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
Definition: tmqh-packetpool.c:305
PROFILE_FLOWWORKER_STREAM
@ PROFILE_FLOWWORKER_STREAM
Definition: flow-worker.h:23
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
FlowQueuePrivate_::len
uint32_t len
Definition: flow-queue.h:43
Flow_::protoctx
void * protoctx
Definition: flow.h:438
OutputLoggerThreadDeinit
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output.c:839
DisableDetectFlowFileFlags
void DisableDetectFlowFileFlags(Flow *f)
disable file features we don't need Called if we have no detection engine.
Definition: detect.c:3295
PacketQueueNoLock_
simple fifo queue for packets
Definition: packet-queue.h:34
tmqh-packetpool.h
StatsCounterDecr
void StatsCounterDecr(StatsThreadContext *stats, StatsCounterId id)
Decrements the local counter.
Definition: counters.c:182
FLOW_TIMEOUT_REASSEMBLY_DONE
#define FLOW_TIMEOUT_REASSEMBLY_DONE
Definition: flow.h:96
FLOWWORKER_PROFILING_START
#define FLOWWORKER_PROFILING_START(p, id)
Definition: util-profiling.h:147
FlowSparePoolReturnFlows
void FlowSparePoolReturnFlows(FlowQueuePrivate *fqp)
Definition: flow-spare-pool.c:120
FLOWLOCK_UNLOCK
#define FLOWLOCK_UNLOCK(fb)
Definition: flow.h:276
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
Flow_::flow_state
FlowStateType flow_state
Definition: flow.h:425
FQLOCK_LOCK
#define FQLOCK_LOCK(q)
Definition: flow-queue.h:72
STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION
Definition: stream-tcp.h:192
FlowWorkerThreadData_::both_bypass_pkts
StatsCounterId both_bypass_pkts
Definition: flow-worker.c:80
TmModule_::ThreadDeinit
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
Definition: tm-modules.h:53
PKT_SET_SRC
#define PKT_SET_SRC(p, src_val)
Definition: decode.h:1366
flow-spare-pool.h
Flow_::alparser
AppLayerParserState * alparser
Definition: flow.h:483
DecodeRegisterPerfCounters
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
Definition: decode.c:647
DetectEngineThreadCtxPtr
DetectEngineThreadCtx * DetectEngineThreadCtxPtr
Definition: flow-worker.c:58
FLOW_STATE_LOCAL_BYPASSED
@ FLOW_STATE_LOCAL_BYPASSED
Definition: flow.h:512
decode.h
PKT_SRC_WIRE
@ PKT_SRC_WIRE
Definition: decode.h:52
FlowWorkerThreadData_::flows_aside_needs_work
StatsCounterId flows_aside_needs_work
Definition: flow-worker.c:91
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:239
DetectEngineThreadCtx_
Definition: detect.h:1316
STREAM_HAS_UNPROCESSED_SEGMENTS_NONE
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NONE
Definition: stream-tcp.h:189
Packet_::ts
SCTime_t ts
Definition: decode.h:570
StatsCounterMaxId
Definition: counters.h:38
PacketDequeueNoLock
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
Definition: packet-queue.c:208
ProfileFlowWorkerId
ProfileFlowWorkerId
Definition: flow-worker.h:21
FlowTimeoutCounters
struct FlowTimeoutCounters FlowTimeoutCounters
FlowHandlePacketUpdate
void FlowHandlePacketUpdate(Flow *f, Packet *p, ThreadVars *tv, DecodeThreadVars *dtv)
Update Packet and Flow.
Definition: flow.c:421
flow-worker.h
PKT_DROP_REASON_FW_FLOW_PRE_HOOK
@ PKT_DROP_REASON_FW_FLOW_PRE_HOOK
Definition: decode.h:411
BOOL2STR
#define BOOL2STR(b)
Definition: util-debug.h:542
FLOWLOCK_WRLOCK
#define FLOWLOCK_WRLOCK(fb)
Definition: flow.h:273
STREAM_FLAGS_FOR_PACKET
#define STREAM_FLAGS_FOR_PACKET(p)
Definition: stream.h:30
FlowWorkerThreadData_::flows_injected_max
StatsCounterMaxId flows_injected_max
Definition: flow-worker.c:89
StreamTcp
TmEcode StreamTcp(ThreadVars *, Packet *, void *, PacketQueueNoLock *pq)
Definition: stream-tcp.c:6137
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
DetectEngineEnabled
int DetectEngineEnabled(void)
Check if detection is enabled.
Definition: detect-engine.c:4109
DecodeThreadVars_::counter_flow_active
StatsCounterId counter_flow_active
Definition: decode.h:1074
Flow_::flow_end_flags
uint8_t flow_end_flags
Definition: flow.h:452
DetectEngineThreadCtxInit
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
Definition: detect-engine.c:3660
TmModule_::Func
TmEcode(* Func)(ThreadVars *, Packet *, void *)
Definition: tm-modules.h:56
FLOW_PKT_TOCLIENT_FIRST
#define FLOW_PKT_TOCLIENT_FIRST
Definition: flow.h:240
PROFILE_FLOWWORKER_APPLAYERUDP
@ PROFILE_FLOWWORKER_APPLAYERUDP
Definition: flow-worker.h:24
FlowQueuePrivateGetFromTop
Flow * FlowQueuePrivateGetFromTop(FlowQueuePrivate *fqc)
Definition: flow-queue.c:151
FLOWWORKER_PROFILING_END
#define FLOWWORKER_PROFILING_END(p, id)
Definition: util-profiling.h:154
StreamTcpPruneSession
void StreamTcpPruneSession(Flow *f, uint8_t flags)
Remove idle TcpSegments from TcpSession.
Definition: stream-tcp-list.c:886
OutputLoggerThreadInit
TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
Definition: output.c:808
app-layer-parser.h
ThreadVars_::id
int id
Definition: threadvars.h:85
BUG_ON
#define BUG_ON(x)
Definition: suricata-common.h:322
util-profiling.h
Packet_
Definition: decode.h:516
tmm_modules
TmModule tmm_modules[TMM_SIZE]
Definition: tm-modules.c:29
GET_PKT_LEN
#define GET_PKT_LEN(p)
Definition: decode.h:209
AppLayerHandleUdp
int AppLayerHandleUdp(ThreadVars *tv, AppLayerThreadCtx *tctx, Packet *p, Flow *f)
Handle a app layer UDP message.
Definition: app-layer.c:878
DEBUG_ASSERT_FLOW_LOCKED
#define DEBUG_ASSERT_FLOW_LOCKED(f)
Definition: util-validate.h:106
TmEcode
TmEcode
Definition: tm-threads-common.h:80
FlowClearMemory
int FlowClearMemory(Flow *f, uint8_t proto_map)
Function clear the flow memory before queueing it to spare flow queue.
Definition: flow.c:1124
TmModuleFlowWorkerRegister
void TmModuleFlowWorkerRegister(void)
Definition: flow-worker.c:802
FlowQueuePrivateAppendPrivate
void FlowQueuePrivateAppendPrivate(FlowQueuePrivate *dest, FlowQueuePrivate *src)
Definition: flow-queue.c:88
flow-timeout.h
TimeSetByThread
void TimeSetByThread(const int thread_id, SCTime_t tv)
Definition: util-time.c:116
FlowWorkerThreadData_::both_bypass_bytes
StatsCounterId both_bypass_bytes
Definition: flow-worker.c:81
TmModule_::name
const char * name
Definition: tm-modules.h:48
UPDATE_DIR_OPPOSING
@ UPDATE_DIR_OPPOSING
Definition: stream-tcp-reassemble.h:57
FlowLookupStruct_::spare_queue
FlowQueuePrivate spare_queue
Definition: flow.h:549
TMM_FLOWWORKER
@ TMM_FLOWWORKER
Definition: tm-threads-common.h:34
Flow_::ffr
uint8_t ffr
Definition: flow.h:393
FlowWorkerGetDetectCtxPtr
void * FlowWorkerGetDetectCtxPtr(void *flow_worker)
Definition: flow-worker.c:747
FlowWorkerThreadData_::stream_thread_ptr
void * stream_thread_ptr
Definition: flow-worker.c:70
FlowQueueExtractPrivate
FlowQueuePrivate FlowQueueExtractPrivate(FlowQueue *fq)
Definition: flow-queue.c:140
FlowWorkerThreadData_::pq
PacketQueueNoLock pq
Definition: flow-worker.c:84
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
app-layer-frames.h
Packet_::flow
struct Flow_ * flow
Definition: decode.h:564
DecodeThreadVarsFree
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
Definition: decode.c:861
flow-manager.h
suricata-common.h
PKT_SRC_FFR
@ PKT_SRC_FFR
Definition: decode.h:58
FlowFree
void FlowFree(Flow *f)
cleanup & free the memory of a flow
Definition: flow-util.c:85
FlowWorkerGetThreadData
void * FlowWorkerGetThreadData(void *flow_worker)
Definition: flow-worker.c:754
PROFILE_FLOWWORKER_SIZE
@ PROFILE_FLOWWORKER_SIZE
Definition: flow-worker.h:29
packet.h
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
DetectEngineThreadCtxDeinit
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
Definition: detect-engine.c:3905
Packet_::app_update_direction
uint8_t app_update_direction
Definition: decode.h:550
FLOW_TS_APP_UPDATED
#define FLOW_TS_APP_UPDATED
Definition: flow.h:118
TmModule_::ThreadInit
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
Definition: tm-modules.h:51
PacketUpdateEngineEventCounters
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
Definition: decode.c:241
PKT_DROP_REASON_FW_STREAM_PRE_HOOK
@ PKT_DROP_REASON_FW_STREAM_PRE_HOOK
Definition: decode.h:410
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:34
Detect
TmEcode Detect(ThreadVars *tv, Packet *p, void *data)
Detection engine thread wrapper.
Definition: detect.c:3226
util-validate.h
FlowQueuePrivate_
Definition: flow-queue.h:40
StreamTcpDetectLogFlush
void StreamTcpDetectLogFlush(ThreadVars *tv, StreamTcpThread *stt, Flow *f, Packet *p, PacketQueueNoLock *pq)
create packets in both directions to flush out logging and detection before switching protocols....
Definition: stream-tcp.c:7122
PacketQueueNoLock_::len
uint32_t len
Definition: packet-queue.h:37
FlowWorkerThreadData_::output_thread_flow
void * output_thread_flow
Definition: flow-worker.c:76
FlowWorkerThreadData_::flows_aside_pkt_inject
StatsCounterId flows_aside_pkt_inject
Definition: flow-worker.c:92
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
OutputFlowLogThreadDeinit
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
Definition: output-flow.c:161
FramesPrune
void FramesPrune(Flow *f, Packet *p)
Definition: app-layer-frames.c:838
OutputLoggerLog
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
Definition: output.c:794
SCFree
#define SCFree(p)
Definition: util-mem.h:61
Packet_::pkt_src
uint8_t pkt_src
Definition: decode.h:626
DecodeThreadVars_
Structure to hold thread specific data for all decode modules.
Definition: decode.h:995
StreamTcpSessionCleanup
void StreamTcpSessionCleanup(TcpSession *ssn)
Session cleanup function. Does not free the ssn.
Definition: stream-tcp.c:335
FlowWorkerThreadData_::fls
FlowLookupStruct fls
Definition: flow-worker.c:85
StatsRegisterMaxCounter
StatsCounterMaxId StatsRegisterMaxCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the maximum of all the values assigned to it.
Definition: counters.c:1076
SC_ATOMIC_INITPTR
#define SC_ATOMIC_INITPTR(name)
Definition: util-atomic.h:317
DecodeThreadVars_::counter_tcp_active_sessions
StatsCounterId counter_tcp_active_sessions
Definition: decode.h:1072
UPDATE_DIR_NONE
@ UPDATE_DIR_NONE
Definition: stream-tcp-reassemble.h:55
DecodeThreadVarsAlloc
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
Definition: decode.c:843
PROFILE_FLOWWORKER_FLOW
@ PROFILE_FLOWWORKER_FLOW
Definition: flow-worker.h:22
StreamTcpThread_::ra_ctx
TcpReassemblyThreadCtx * ra_ctx
Definition: stream-tcp.h:117
FlowWorkerThreadData_::cnt
struct FlowWorkerThreadData_::@124 cnt
PacketDrop
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
Definition: packet.c:34
EngineModeIsIPS
int EngineModeIsIPS(void)
Definition: suricata.c:247
DetectEngineThreadCtx_::de_ctx
DetectEngineCtx * de_ctx
Definition: detect.h:1444
suricata.h
StreamUpdateDir
StreamUpdateDir
Definition: stream-tcp-reassemble.h:54
FlowWorkerThreadData_::flows_injected
StatsCounterId flows_injected
Definition: flow-worker.c:88
FLOW_END_FLAG_TIMEOUT
#define FLOW_END_FLAG_TIMEOUT
Definition: flow.h:246
FlowWorkerThreadData_::fec
FlowEndCounters fec
Definition: flow-worker.c:94
likely
#define likely(expr)
Definition: util-optimize.h:32
FlowNeedsReassembly
bool FlowNeedsReassembly(Flow *f)
Check if a flow needs forced reassembly, or any other processing.
Definition: flow-timeout.c:285
FlowWorkerThreadData_::output_thread
void * output_thread
Definition: flow-worker.c:75
FlowChangeProto
int FlowChangeProto(Flow *f)
Check if change proto flag is set for flow.
Definition: flow.c:194
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:375
TcpSession_
Definition: stream-tcp-private.h:283
FlowEndCountersRegister
void FlowEndCountersRegister(ThreadVars *t, FlowEndCounters *fec)
Definition: flow-util.c:246
FlowWorkerThreadData_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(DetectEngineThreadCtxPtr, detect_thread)
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:120
FlowEndCounters_
Definition: flow-util.h:146
FLOW_SPARE_POOL_BLOCK_SIZE
#define FLOW_SPARE_POOL_BLOCK_SIZE
Definition: flow-spare-pool.h:30
StatsCounterAddI64
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
Definition: counters.c:144
FLOW_PKT_TOSERVER_FIRST
#define FLOW_PKT_TOSERVER_FIRST
Definition: flow.h:239
FlowWorkerThreadData_::local_bypass_bytes
StatsCounterId local_bypass_bytes
Definition: flow-worker.c:79
DEBUG_VALIDATE_BUG_ON
#define DEBUG_VALIDATE_BUG_ON(exp)
Definition: util-validate.h:109
PKT_DROP_REASON_FLOW_DROP
@ PKT_DROP_REASON_FLOW_DROP
Definition: decode.h:389
TmModule_::flags
uint8_t flags
Definition: tm-modules.h:80
FlowWorkerThreadData_
Definition: flow-worker.c:65
FLOW_TS_APP_UPDATE_NEXT
#define FLOW_TS_APP_UPDATE_NEXT
Definition: flow.h:122
StreamTcpThreadDeinit
TmEcode StreamTcpThreadDeinit(ThreadVars *tv, void *data)
Definition: stream-tcp.c:6268
output.h
PKT_STREAM_EST
#define PKT_STREAM_EST
Definition: decode.h:1307
TM_FLAG_FLOWWORKER_TM
#define TM_FLAG_FLOWWORKER_TM
Definition: tm-modules.h:34
FlowWorkerReplaceDetectCtx
void FlowWorkerReplaceDetectCtx(void *flow_worker, void *detect_ctx)
Definition: flow-worker.c:740
app-layer.h
FlowTimeoutCounters::flows_aside_needs_work
uint32_t flows_aside_needs_work
Definition: flow-worker.c:61
FQLOCK_UNLOCK
#define FQLOCK_UNLOCK(q)
Definition: flow-queue.h:74
f
Flow f
Definition: fuzz_dataset.c:32