50 #define THREADS_MAX (uint16_t)1024
63 size_t queues_size = n * 13;
66 char *queues =
SCCalloc(1, queues_size);
68 SCLogError(
"failed to alloc queues buffer: %s", strerror(errno));
72 for (
int thread = 0; thread < n; thread++) {
73 if (strlen(queues) > 0)
74 strlcat(queues,
",", queues_size);
76 snprintf(qname,
sizeof(qname),
"pickup%d", (int16_t)thread+1);
77 strlcat(queues, qname, queues_size);
80 SCLogDebug(
"%d %"PRIuMAX
", queues %s", n, (uintmax_t)queues_size, queues);
88 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
99 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
102 if ((nlive <= 1) && (live_dev != NULL)) {
105 void *aconf = ConfigParser(live_dev);
107 FatalError(
"Failed to allocate config for %s", live_dev);
110 const uint16_t threads_count =
MIN(ModThreadsCount(aconf),
THREADS_MAX);
111 SCLogInfo(
"Going to use %" PRIu16
" %s receive thread(s)", threads_count, recv_mod_name);
114 for (uint16_t thread = 0; thread < threads_count; thread++) {
115 const uint16_t thread_id = (uint16_t)(thread + 1);
116 snprintf(tname,
sizeof(tname),
"%s#%02u", thread_name, thread_id);
119 "packetpool",
"packetpool",
120 queues,
"flow",
"pktacqloop");
121 if (tv_receive == NULL) {
125 if (tm_module == NULL) {
126 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
131 if (tm_module == NULL) {
132 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
143 SCLogInfo(
"Using %d live device(s).", nlive);
145 for (
int lthread = 0; lthread < nlive; lthread++) {
150 FatalError(
"Failed to lookup live dev %d", lthread);
154 void *aconf = ConfigParser(dev);
156 FatalError(
"Multidev: Failed to allocate config for %s (%d)", dev, lthread);
159 const uint16_t threads_count =
MIN(ModThreadsCount(aconf),
THREADS_MAX);
160 for (uint16_t thread = 0; thread < threads_count; thread++) {
161 const uint16_t thread_id = (uint16_t)(thread + 1);
162 const size_t printable_threadname_size = strlen(thread_name) + 5 + strlen(dev) + 1;
163 char *printable_threadname =
SCMalloc(printable_threadname_size);
164 if (
unlikely(printable_threadname == NULL)) {
165 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
168 tname,
sizeof(tname),
"%s#%02u-%s", thread_name, thread_id, visual_devname);
169 snprintf(printable_threadname, printable_threadname_size,
"%s#%02u-%s", thread_name,
174 "packetpool",
"packetpool",
175 queues,
"flow",
"pktacqloop");
176 if (tv_receive == NULL) {
182 FatalError(
"Failed to allocate memory for iface name");
186 if (tm_module == NULL) {
187 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
192 if (tm_module == NULL) {
193 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
206 for (uint16_t thread = 0; thread < thread_max; thread++) {
207 const uint16_t thread_id = (uint16_t)(thread + 1);
209 snprintf(qname,
sizeof(qname),
"pickup%u", thread_id);
210 SCLogDebug(
"tname %s, qname %s", tname, qname);
215 "packetpool",
"packetpool",
217 if (tv_detect_ncpu == NULL) {
221 if (tm_module == NULL) {
222 FatalError(
"TmModuleGetByName for FlowWorker failed");
229 if (tm_module == NULL) {
230 FatalError(
"TmModuleGetByName RespondReject failed");
246 const char *recv_mod_name,
247 const char *decode_mod_name,
const char *thread_name,
248 const char *live_dev,
void *aconf,
249 unsigned char single_mode)
251 uint16_t threads_count;
257 threads_count =
MIN(ModThreadsCount(aconf), thread_max);
258 SCLogInfo(
"%s: creating %" PRIu16
" thread%s", live_dev, threads_count,
259 threads_count > 1 ?
"s" :
"");
263 for (uint16_t thread = 0; thread < threads_count; thread++) {
264 const uint16_t thread_id = (uint16_t)(thread + 1);
266 const size_t printable_threadname_size = strlen(thread_name) + 5 + strlen(live_dev) + 1;
267 char *printable_threadname =
SCMalloc(printable_threadname_size);
268 if (
unlikely(printable_threadname == NULL)) {
269 FatalError(
"failed to alloc printable thread name: %s", strerror(errno));
275 snprintf(tname,
sizeof(tname),
"%s#01-%s", thread_name, visual_devname);
276 snprintf(printable_threadname, printable_threadname_size,
"%s#01-%s", thread_name,
279 snprintf(tname,
sizeof(tname),
"%s#%02u-%s", thread_name, thread_id, visual_devname);
280 snprintf(printable_threadname, printable_threadname_size,
"%s#%02u-%s", thread_name,
281 thread_id, live_dev);
284 "packetpool",
"packetpool",
285 "packetpool",
"packetpool",
293 FatalError(
"Failed to allocate memory for iface name");
297 if (tm_module == NULL) {
298 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
303 if (tm_module == NULL) {
304 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
309 if (tm_module == NULL) {
310 FatalError(
"TmModuleGetByName for FlowWorker failed");
315 if (tm_module == NULL) {
316 FatalError(
"TmModuleGetByName RespondReject failed");
332 const char *decode_mod_name,
const char *thread_name,
const char *live_dev)
336 for (
int ldev = 0; ldev < nlive; ldev++) {
337 const char *live_dev_c = NULL;
340 if ((nlive <= 1) && (live_dev != NULL)) {
341 aconf = ConfigParser(live_dev);
342 live_dev_c = live_dev;
345 aconf = ConfigParser(live_dev_c);
347 RunModeSetLiveCaptureWorkersForDevice(
348 ModThreadsCount, recv_mod_name, decode_mod_name, thread_name, live_dev_c, aconf, 0);
356 const char *recv_mod_name,
357 const char *decode_mod_name,
const char *thread_name,
358 const char *live_dev)
361 const char *live_dev_c = NULL;
365 FatalError(
"Can't use the 'single' runmode with multiple devices");
368 if (live_dev != NULL) {
369 aconf = ConfigParser(live_dev);
370 live_dev_c = live_dev;
373 aconf = ConfigParser(live_dev_c);
376 return RunModeSetLiveCaptureWorkersForDevice(
377 ModThreadsCount, recv_mod_name, decode_mod_name, thread_name, live_dev_c, aconf, 1);
384 const char *recv_mod_name,
385 const char *verdict_mod_name,
386 const char *decode_mod_name)
396 if (queues == NULL) {
397 FatalError(
"RunmodeAutoFpCreatePickupQueuesString failed");
401 for (
int i = 0; i < nqueue; i++) {
403 if (cur_queue == NULL) {
406 memset(tname, 0,
sizeof(tname));
411 "packetpool",
"packetpool",
412 queues,
"flow",
"pktacqloop");
413 if (tv_receive == NULL) {
417 if (tm_module == NULL) {
418 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
423 if (tm_module == NULL) {
424 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
435 for (uint16_t thread = 0; thread < thread_max; thread++) {
436 const uint16_t thread_id = (uint16_t)(thread + 1);
439 snprintf(qname,
sizeof(qname),
"pickup%u", thread_id);
440 SCLogDebug(
"tname %s, qname %s", tname, qname);
445 "verdict-queue",
"simple",
447 if (tv_detect_ncpu == NULL) {
452 if (tm_module == NULL) {
453 FatalError(
"TmModuleGetByName for FlowWorker failed");
465 for (
int i = 0; i < nqueue; i++) {
466 memset(tname, 0,
sizeof(tname));
471 "verdict-queue",
"simple",
472 "packetpool",
"packetpool",
474 if (tv_verdict == NULL) {
478 if (tm_module == NULL) {
479 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
484 if (tm_module == NULL) {
485 FatalError(
"TmModuleGetByName for RespondReject failed");
503 const char *recv_mod_name,
504 const char *verdict_mod_name,
505 const char *decode_mod_name)
509 for (
int i = 0; i < nqueue; i++) {
512 if (cur_queue == NULL) {
517 memset(tname, 0,
sizeof(tname));
521 "packetpool",
"packetpool",
522 "packetpool",
"packetpool",
529 if (tm_module == NULL) {
530 FatalError(
"TmModuleGetByName failed for %s", recv_mod_name);
535 if (tm_module == NULL) {
536 FatalError(
"TmModuleGetByName %s failed", decode_mod_name);
541 if (tm_module == NULL) {
542 FatalError(
"TmModuleGetByName for FlowWorker failed");
547 if (tm_module == NULL) {
548 FatalError(
"TmModuleGetByName %s failed", verdict_mod_name);
553 if (tm_module == NULL) {
554 FatalError(
"TmModuleGetByName for RespondReject failed");