suricata
util-runmodes.c
Go to the documentation of this file.
1 /* Copyright (C) 2011-2019 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 Eric Leblond <eric@regit.org>
22  *
23  * Helper function for runmode.
24  *
25  */
26 
27 #include "suricata-common.h"
28 #include "config.h"
29 #include "tm-threads.h"
30 #include "conf.h"
31 #include "runmodes.h"
32 #include "runmode-af-packet.h"
33 #include "output.h"
34 #include "log-httplog.h"
35 
36 #include "detect-engine.h"
37 #include "detect-engine-mpm.h"
38 
39 #include "alert-fastlog.h"
40 #include "alert-prelude.h"
41 #include "alert-debuglog.h"
42 
43 #include "util-debug.h"
44 #include "util-time.h"
45 #include "util-cpu.h"
46 #include "util-affinity.h"
47 #include "util-device.h"
48 
49 #include "util-runmodes.h"
50 
51 #include "flow-hash.h"
52 
53 /** \brief create a queue string for autofp to pass to
54  * the flow queue handler.
55  *
56  * The string will be "pickup1,pickup2,pickup3\0"
57  */
59 {
60  if (n > 1024)
61  return NULL;
62 
63  /* 13 because pickup12345, = 12 + \0 */
64  size_t queues_size = n * 13;
65  char qname[TM_QUEUE_NAME_MAX];
66 
67  char *queues = SCMalloc(queues_size);
68  if (unlikely(queues == NULL)) {
69  SCLogError(SC_ERR_MEM_ALLOC, "failed to alloc queues buffer: %s",
70  strerror(errno));
71  return NULL;
72  }
73  memset(queues, 0x00, queues_size);
74 
75  for (int thread = 0; thread < n; thread++) {
76  if (strlen(queues) > 0)
77  strlcat(queues, ",", queues_size);
78 
79  snprintf(qname, sizeof(qname), "pickup%d", (int16_t)thread+1);
80  strlcat(queues, qname, queues_size);
81  }
82 
83  SCLogDebug("%d %"PRIuMAX", queues %s", n, (uintmax_t)queues_size, queues);
84  return queues;
85 }
86 
87 /**
88  */
90  ConfigIfaceThreadsCountFunc ModThreadsCount,
91  const char *recv_mod_name,
92  const char *decode_mod_name,
93  const char *thread_name,
94  const char *live_dev)
95 {
96  char tname[TM_THREAD_NAME_MAX];
97  char qname[TM_QUEUE_NAME_MAX];
98 
99  /* Available cpus */
100  uint16_t ncpus = UtilCpuGetNumProcessorsOnline();
101  int nlive = LiveGetDeviceCount();
102  int thread_max = TmThreadGetNbThreads(WORKER_CPU_SET);
103  /* always create at least one thread */
104  if (thread_max == 0)
105  thread_max = ncpus * threading_detect_ratio;
106  if (thread_max < 1)
107  thread_max = 1;
108  if (thread_max > 1024) {
109  SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
110  thread_max = 1024;
111  }
112 
113  char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
114  if (queues == NULL) {
115  FatalError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
116  }
117 
118  if ((nlive <= 1) && (live_dev != NULL)) {
119  SCLogDebug("live_dev %s", live_dev);
120 
121  void *aconf = ConfigParser(live_dev);
122  if (aconf == NULL) {
123  FatalError(SC_ERR_RUNMODE, "Failed to allocate config for %s",
124  live_dev);
125  }
126 
127  int threads_count = ModThreadsCount(aconf);
128  SCLogInfo("Going to use %" PRId32 " %s receive thread(s)",
129  threads_count, recv_mod_name);
130 
131  /* create the threads */
132  for (int thread = 0; thread < MIN(thread_max, threads_count); thread++) {
133  snprintf(tname, sizeof(tname), "%s#%02d", thread_name, thread+1);
134  ThreadVars *tv_receive =
136  "packetpool", "packetpool",
137  queues, "flow", "pktacqloop");
138  if (tv_receive == NULL) {
139  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
140  }
141  TmModule *tm_module = TmModuleGetByName(recv_mod_name);
142  if (tm_module == NULL) {
144  "TmModuleGetByName failed for %s",
145  recv_mod_name);
146  }
147  TmSlotSetFuncAppend(tv_receive, tm_module, aconf);
148 
149  tm_module = TmModuleGetByName(decode_mod_name);
150  if (tm_module == NULL) {
152  "TmModuleGetByName %s failed", decode_mod_name);
153  }
154  TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
155 
156  TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
157 
158  if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
159  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
160  }
161  }
162  } else { /* Multiple input device */
163  SCLogInfo("Using %d live device(s).", nlive);
164 
165  for (int lthread = 0; lthread < nlive; lthread++) {
166  const char *dev = LiveGetDeviceName(lthread);
167  const char *visual_devname = LiveGetShortName(dev);
168 
169  if (dev == NULL) {
170  FatalError(SC_ERR_RUNMODE, "Failed to lookup live dev %d", lthread);
171  }
172  SCLogDebug("dev %s", dev);
173 
174  void *aconf = ConfigParser(dev);
175  if (aconf == NULL) {
176  FatalError(SC_ERR_RUNMODE, "Multidev: Failed to allocate config for %s (%d)",
177  dev, lthread);
178  }
179 
180  int threads_count = ModThreadsCount(aconf);
181  for (int thread = 0; thread < threads_count; thread++) {
182  char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(dev)));
183  if (unlikely(printable_threadname == NULL)) {
184  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc printable thread name: %s", strerror(errno));
185  }
186  snprintf(tname, sizeof(tname), "%s#%02d-%s", thread_name,
187  thread+1, visual_devname);
188  snprintf(printable_threadname, strlen(thread_name)+5+strlen(dev),
189  "%s#%02d-%s", thread_name, thread+1,
190  dev);
191 
192  ThreadVars *tv_receive =
194  "packetpool", "packetpool",
195  queues, "flow", "pktacqloop");
196  if (tv_receive == NULL) {
197  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
198  }
199  tv_receive->printable_name = printable_threadname;
200  TmModule *tm_module = TmModuleGetByName(recv_mod_name);
201  if (tm_module == NULL) {
202  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName failed for %s", recv_mod_name);
203  }
204  TmSlotSetFuncAppend(tv_receive, tm_module, aconf);
205 
206  tm_module = TmModuleGetByName(decode_mod_name);
207  if (tm_module == NULL) {
208  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", decode_mod_name);
209  }
210  TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
211 
212  TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
213 
214  if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
215  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
216  }
217  }
218  }
219  }
220 
221  for (int thread = 0; thread < thread_max; thread++) {
222  snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
223  snprintf(qname, sizeof(qname), "pickup%u", thread+1);
224 
225  SCLogDebug("tname %s, qname %s", tname, qname);
226 
227  ThreadVars *tv_detect_ncpu =
229  qname, "flow",
230  "packetpool", "packetpool",
231  "varslot");
232  if (tv_detect_ncpu == NULL) {
233  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
234  }
235  TmModule *tm_module = TmModuleGetByName("FlowWorker");
236  if (tm_module == NULL) {
237  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
238  }
239  TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
240 
241  TmThreadSetCPU(tv_detect_ncpu, WORKER_CPU_SET);
242 
243  TmThreadSetGroupName(tv_detect_ncpu, "Detect");
244 
245  tm_module = TmModuleGetByName("RespondReject");
246  if (tm_module == NULL) {
247  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName RespondReject failed");
248  }
249  TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
250 
251  if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
252  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
253  }
254  }
255 
256  SCFree(queues);
257  return 0;
258 }
259 
260 /**
261  */
262 static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc ModThreadsCount,
263  const char *recv_mod_name,
264  const char *decode_mod_name, const char *thread_name,
265  const char *live_dev, void *aconf,
266  unsigned char single_mode)
267 {
268  int threads_count;
269 
270  if (single_mode) {
271  threads_count = 1;
272  } else {
273  threads_count = ModThreadsCount(aconf);
274  SCLogInfo("Going to use %" PRId32 " thread(s)", threads_count);
275  }
276 
277  /* create the threads */
278  for (int thread = 0; thread < threads_count; thread++) {
279  char tname[TM_THREAD_NAME_MAX];
280  TmModule *tm_module = NULL;
281  const char *visual_devname = LiveGetShortName(live_dev);
282  char *printable_threadname = SCMalloc(sizeof(char) * (strlen(thread_name)+5+strlen(live_dev)));
283  if (unlikely(printable_threadname == NULL)) {
284  FatalError(SC_ERR_MEM_ALLOC, "failed to alloc printable thread name: %s", strerror(errno));
285  exit(EXIT_FAILURE);
286  }
287 
288  if (single_mode) {
289  snprintf(tname, sizeof(tname), "%s#01-%s", thread_name, visual_devname);
290  snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev), "%s#01-%s",
291  thread_name, live_dev);
292  } else {
293  snprintf(tname, sizeof(tname), "%s#%02d-%s", thread_name,
294  thread+1, visual_devname);
295  snprintf(printable_threadname, strlen(thread_name)+5+strlen(live_dev), "%s#%02d-%s",
296  thread_name, thread+1, live_dev);
297  }
299  "packetpool", "packetpool",
300  "packetpool", "packetpool",
301  "pktacqloop");
302  if (tv == NULL) {
303  FatalError(SC_ERR_THREAD_CREATE, "TmThreadsCreate failed");
304  }
305  tv->printable_name = printable_threadname;
306 
307  tm_module = TmModuleGetByName(recv_mod_name);
308  if (tm_module == NULL) {
309  FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName failed for %s", recv_mod_name);
310  }
311  TmSlotSetFuncAppend(tv, tm_module, aconf);
312 
313  tm_module = TmModuleGetByName(decode_mod_name);
314  if (tm_module == NULL) {
315  FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName %s failed", decode_mod_name);
316  }
317  TmSlotSetFuncAppend(tv, tm_module, NULL);
318 
319  tm_module = TmModuleGetByName("FlowWorker");
320  if (tm_module == NULL) {
321  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
322  }
323  TmSlotSetFuncAppend(tv, tm_module, NULL);
324 
325  tm_module = TmModuleGetByName("RespondReject");
326  if (tm_module == NULL) {
327  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName RespondReject failed");
328  }
329  TmSlotSetFuncAppend(tv, tm_module, NULL);
330 
332 
333  if (TmThreadSpawn(tv) != TM_ECODE_OK) {
334  FatalError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed");
335  }
336  }
337 
338  return 0;
339 }
340 
342  ConfigIfaceThreadsCountFunc ModThreadsCount,
343  const char *recv_mod_name,
344  const char *decode_mod_name, const char *thread_name,
345  const char *live_dev)
346 {
347  int nlive = LiveGetDeviceCount();
348  void *aconf;
349  int ldev;
350 
351  for (ldev = 0; ldev < nlive; ldev++) {
352  const char *live_dev_c = NULL;
353  if ((nlive <= 1) && (live_dev != NULL)) {
354  aconf = ConfigParser(live_dev);
355  live_dev_c = live_dev;
356  if (unlikely(live_dev_c == NULL)) {
357  FatalError(SC_ERR_MEM_ALLOC, "Can't allocate interface name");
358  }
359  } else {
360  live_dev_c = LiveGetDeviceName(ldev);
361  aconf = ConfigParser(live_dev_c);
362  }
363  RunModeSetLiveCaptureWorkersForDevice(ModThreadsCount,
364  recv_mod_name,
365  decode_mod_name,
366  thread_name,
367  live_dev_c,
368  aconf,
369  0);
370  }
371 
372  return 0;
373 }
374 
376  ConfigIfaceThreadsCountFunc ModThreadsCount,
377  const char *recv_mod_name,
378  const char *decode_mod_name, const char *thread_name,
379  const char *live_dev)
380 {
381  int nlive = LiveGetDeviceCount();
382  const char *live_dev_c = NULL;
383  void *aconf;
384 
385  if (nlive > 1) {
387  "Can't use the 'single' runmode with multiple devices");
388  }
389 
390  if (live_dev != NULL) {
391  aconf = ConfigParser(live_dev);
392  live_dev_c = live_dev;
393  } else {
394  live_dev_c = LiveGetDeviceName(0);
395  aconf = ConfigParser(live_dev_c);
396  }
397 
398  return RunModeSetLiveCaptureWorkersForDevice(
399  ModThreadsCount,
400  recv_mod_name,
401  decode_mod_name,
402  thread_name,
403  live_dev_c,
404  aconf,
405  1);
406 }
407 
408 
409 /**
410  */
412  const char *recv_mod_name,
413  const char *verdict_mod_name,
414  const char *decode_mod_name)
415 {
416  SCEnter();
417  char tname[TM_THREAD_NAME_MAX];
418  TmModule *tm_module ;
419 
420  /* Available cpus */
421  uint16_t ncpus = UtilCpuGetNumProcessorsOnline();
422  const int nqueue = LiveGetDeviceCount();
423 
424  int thread_max = TmThreadGetNbThreads(WORKER_CPU_SET);
425  /* always create at least one thread */
426  if (thread_max == 0)
427  thread_max = ncpus * threading_detect_ratio;
428  if (thread_max < 1)
429  thread_max = 1;
430  if (thread_max > 1024) {
431  SCLogWarning(SC_ERR_RUNMODE, "limited number of 'worker' threads to 1024. Wanted %d", thread_max);
432  thread_max = 1024;
433  }
434 
435  char *queues = RunmodeAutoFpCreatePickupQueuesString(thread_max);
436  if (queues == NULL) {
437  FatalError(SC_ERR_RUNMODE, "RunmodeAutoFpCreatePickupQueuesString failed");
438  }
439 
440  /* create the threads */
441  for (int i = 0; i < nqueue; i++) {
442  const char *cur_queue = LiveGetDeviceName(i);
443  if (cur_queue == NULL) {
444  FatalError(SC_ERR_RUNMODE, "invalid queue number");
445  }
446  memset(tname, 0, sizeof(tname));
447  snprintf(tname, sizeof(tname), "%s-%s", thread_name_autofp, cur_queue);
448 
449  ThreadVars *tv_receive =
451  "packetpool", "packetpool",
452  queues, "flow", "pktacqloop");
453  if (tv_receive == NULL) {
454  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
455  }
456  tm_module = TmModuleGetByName(recv_mod_name);
457  if (tm_module == NULL) {
458  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName failed for %s", recv_mod_name);
459  }
460  TmSlotSetFuncAppend(tv_receive, tm_module, (void *) ConfigParser(i));
461 
462  tm_module = TmModuleGetByName(decode_mod_name);
463  if (tm_module == NULL) {
464  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", decode_mod_name);
465  }
466  TmSlotSetFuncAppend(tv_receive, tm_module, NULL);
467 
468  TmThreadSetCPU(tv_receive, RECEIVE_CPU_SET);
469 
470  if (TmThreadSpawn(tv_receive) != TM_ECODE_OK) {
471  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
472  }
473 
474  }
475  for (int thread = 0; thread < thread_max; thread++) {
476  snprintf(tname, sizeof(tname), "%s#%02u", thread_name_workers, thread+1);
477  char qname[TM_QUEUE_NAME_MAX];
478  snprintf(qname, sizeof(qname), "pickup%u", thread+1);
479 
480  SCLogDebug("tname %s, qname %s", tname, qname);
481 
482  ThreadVars *tv_detect_ncpu =
484  qname, "flow",
485  "verdict-queue", "simple",
486  "varslot");
487  if (tv_detect_ncpu == NULL) {
488  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
489  }
490 
491  tm_module = TmModuleGetByName("FlowWorker");
492  if (tm_module == NULL) {
493  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
494  }
495  TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL);
496 
497  TmThreadSetCPU(tv_detect_ncpu, WORKER_CPU_SET);
498 
499  TmThreadSetGroupName(tv_detect_ncpu, "Detect");
500 
501  if (TmThreadSpawn(tv_detect_ncpu) != TM_ECODE_OK) {
502  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
503  }
504  }
505 
506  /* create the threads */
507  for (int i = 0; i < nqueue; i++) {
508  memset(tname, 0, sizeof(tname));
509  snprintf(tname, sizeof(tname), "%s#%02d", thread_name_verdict, i);
510 
511  ThreadVars *tv_verdict =
513  "verdict-queue", "simple",
514  "packetpool", "packetpool",
515  "varslot");
516  if (tv_verdict == NULL) {
517  FatalError(SC_ERR_RUNMODE, "TmThreadsCreate failed");
518  }
519  tm_module = TmModuleGetByName(verdict_mod_name);
520  if (tm_module == NULL) {
521  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", verdict_mod_name);
522  }
523  TmSlotSetFuncAppend(tv_verdict, tm_module, (void *)ConfigParser(i));
524 
525  tm_module = TmModuleGetByName("RespondReject");
526  if (tm_module == NULL) {
527  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for RespondReject failed");
528  }
529  TmSlotSetFuncAppend(tv_verdict, tm_module, NULL);
530 
531  TmThreadSetCPU(tv_verdict, VERDICT_CPU_SET);
532 
533  if (TmThreadSpawn(tv_verdict) != TM_ECODE_OK) {
534  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
535  }
536  }
537 
538  SCFree(queues);
539  return 0;
540 }
541 
542 /**
543  */
545  const char *recv_mod_name,
546  const char *verdict_mod_name,
547  const char *decode_mod_name)
548 {
549  TmModule *tm_module = NULL;
550  const int nqueue = LiveGetDeviceCount();
551 
552  for (int i = 0; i < nqueue; i++) {
553  /* create the threads */
554  const char *cur_queue = LiveGetDeviceName(i);
555  if (cur_queue == NULL) {
556  FatalError(SC_ERR_RUNMODE, "invalid queue number");
557  }
558 
559  char tname[TM_THREAD_NAME_MAX];
560  memset(tname, 0, sizeof(tname));
561  snprintf(tname, sizeof(tname), "%s-%s", thread_name_workers, cur_queue);
562 
564  "packetpool", "packetpool",
565  "packetpool", "packetpool",
566  "pktacqloop");
567  if (tv == NULL) {
568  FatalError(SC_ERR_THREAD_CREATE, "TmThreadsCreate failed");
569  }
570 
571  tm_module = TmModuleGetByName(recv_mod_name);
572  if (tm_module == NULL) {
573  FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName failed for %s", recv_mod_name);
574  }
575  TmSlotSetFuncAppend(tv, tm_module, (void *) ConfigParser(i));
576 
577  tm_module = TmModuleGetByName(decode_mod_name);
578  if (tm_module == NULL) {
579  FatalError(SC_ERR_INVALID_VALUE, "TmModuleGetByName %s failed", decode_mod_name);
580  }
581  TmSlotSetFuncAppend(tv, tm_module, NULL);
582 
583  tm_module = TmModuleGetByName("FlowWorker");
584  if (tm_module == NULL) {
585  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for FlowWorker failed");
586  }
587  TmSlotSetFuncAppend(tv, tm_module, NULL);
588 
589  tm_module = TmModuleGetByName(verdict_mod_name);
590  if (tm_module == NULL) {
591  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName %s failed", verdict_mod_name);
592  }
593  TmSlotSetFuncAppend(tv, tm_module, (void *) ConfigParser(i));
594 
595  tm_module = TmModuleGetByName("RespondReject");
596  if (tm_module == NULL) {
597  FatalError(SC_ERR_RUNMODE, "TmModuleGetByName for RespondReject failed");
598  }
599  TmSlotSetFuncAppend(tv, tm_module, NULL);
600 
602 
603  if (TmThreadSpawn(tv) != TM_ECODE_OK) {
604  FatalError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
605  }
606  }
607 
608  return 0;
609 }
thread_name_workers
const char * thread_name_workers
Definition: runmodes.c:63
VERDICT_CPU_SET
@ VERDICT_CPU_SET
Definition: util-affinity.h:53
tm-threads.h
RunModeSetIPSAutoFp
int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser, const char *recv_mod_name, const char *verdict_mod_name, const char *decode_mod_name)
Definition: util-runmodes.c:411
TmThreadSpawn
TmEcode TmThreadSpawn(ThreadVars *tv)
Spawns a thread associated with the ThreadVars instance tv.
Definition: tm-threads.c:1630
detect-engine.h
RunModeSetLiveCaptureWorkers
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:341
SC_ERR_INVALID_VALUE
@ SC_ERR_INVALID_VALUE
Definition: util-error.h:160
alert-debuglog.h
LiveGetShortName
const char * LiveGetShortName(const char *dev)
Definition: util-device.c:300
runmode-af-packet.h
TmThreadCreatePacketHandler
ThreadVars * TmThreadCreatePacketHandler(const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots)
Creates and returns a TV instance for a Packet Processing Thread. This function doesn't support custo...
Definition: tm-threads.c:1041
SCFree
#define SCFree(a)
Definition: util-mem.h:322
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
TmThreadSetGroupName
void TmThreadSetGroupName(ThreadVars *tv, const char *name)
Definition: tm-threads.c:1587
RunModeSetIPSWorker
int RunModeSetIPSWorker(ConfigIPSParserFunc ConfigParser, const char *recv_mod_name, const char *verdict_mod_name, const char *decode_mod_name)
Definition: util-runmodes.c:544
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:335
flow-hash.h
util-runmodes.h
thread_name_autofp
const char * thread_name_autofp
Definition: runmodes.c:61
MIN
#define MIN(x, y)
Definition: suricata-common.h:360
SC_ERR_THREAD_CREATE
@ SC_ERR_THREAD_CREATE
Definition: util-error.h:78
SC_ERR_RUNMODE
@ SC_ERR_RUNMODE
Definition: util-error.h:219
TM_THREAD_NAME_MAX
#define TM_THREAD_NAME_MAX
Definition: tm-threads.h:48
ConfigIfaceThreadsCountFunc
int(* ConfigIfaceThreadsCountFunc)(void *)
Definition: util-runmodes.h:28
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:78
RunModeSetLiveCaptureAutoFp
int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:89
TmModuleGetByName
TmModule * TmModuleGetByName(const char *name)
get a tm module ptr by name
Definition: tm-modules.c:53
util-device.h
util-debug.h
RunmodeAutoFpCreatePickupQueuesString
char * RunmodeAutoFpCreatePickupQueuesString(int n)
create a queue string for autofp to pass to the flow queue handler.
Definition: util-runmodes.c:58
strlcat
size_t strlcat(char *, const char *src, size_t siz)
Definition: util-strlcatu.c:45
util-cpu.h
ConfigIPSParserFunc
void *(* ConfigIPSParserFunc)(int)
Definition: util-runmodes.h:27
SCEnter
#define SCEnter(...)
Definition: util-debug.h:337
detect-engine-mpm.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
util-affinity.h
util-time.h
SCMalloc
#define SCMalloc(a)
Definition: util-mem.h:222
TM_QUEUE_NAME_MAX
#define TM_QUEUE_NAME_MAX
Definition: tm-threads.h:47
conf.h
runmodes.h
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:254
alert-prelude.h
TmModule_
Definition: tm-modules.h:43
alert-fastlog.h
TmSlotSetFuncAppend
void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data)
Appends a new entry to the slots.
Definition: tm-threads.c:623
suricata-common.h
TmThreadSetCPU
TmEcode TmThreadSetCPU(ThreadVars *tv, uint8_t type)
Definition: tm-threads.c:820
LiveGetDeviceName
const char * LiveGetDeviceName(int number)
Get a pointer to the device name at idx.
Definition: util-device.c:177
TmThreadGetNbThreads
int TmThreadGetNbThreads(uint8_t type)
Definition: tm-threads.c:836
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
FatalError
#define FatalError(x,...)
Definition: util-debug.h:569
ThreadVars_::printable_name
char * printable_name
Definition: threadvars.h:65
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
log-httplog.h
ConfigIfaceParserFunc
void *(* ConfigIfaceParserFunc)(const char *)
Definition: util-runmodes.h:26
SCLogWarning
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
thread_name_verdict
const char * thread_name_verdict
Definition: runmodes.c:64
RunModeSetLiveCaptureSingle
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:375
SC_ERR_THREAD_SPAWN
@ SC_ERR_THREAD_SPAWN
Definition: util-error.h:76
RECEIVE_CPU_SET
@ RECEIVE_CPU_SET
Definition: util-affinity.h:51
SC_ERR_MEM_ALLOC
@ SC_ERR_MEM_ALLOC
Definition: util-error.h:31
LiveGetDeviceCount
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:157
UtilCpuGetNumProcessorsOnline
uint16_t UtilCpuGetNumProcessorsOnline(void)
Get the number of cpus online in the system.
Definition: util-cpu.c:99
threading_detect_ratio
float threading_detect_ratio
Definition: runmodes.c:902
output.h
WORKER_CPU_SET
@ WORKER_CPU_SET
Definition: util-affinity.h:52