suricata
util-device.c
Go to the documentation of this file.
1 /* Copyright (C) 2011-2021 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 #include "suricata-common.h"
19 #include "conf.h"
20 #include "util-device-private.h"
21 #include "util-ioctl.h"
22 #include "util-misc.h"
23 #include "util-dpdk.h"
24 
25 #include "device-storage.h"
26 #include "util-debug.h"
27 
28 #define MAX_DEVNAME 10
29 
30 static LiveDevStorageId g_bypass_storage_id = { .id = -1 };
31 
32 /**
33  * \file
34  *
35  * \author Eric Leblond <eric@regit.org>
36  *
37  * \brief Utility functions to handle device list
38  */
39 
40 /** private device list */
41 static TAILQ_HEAD(, LiveDevice_) live_devices =
42  TAILQ_HEAD_INITIALIZER(live_devices);
43 
44 typedef struct LiveDeviceName_ {
45  char *dev; /**< the device (e.g. "eth0") */
46  TAILQ_ENTRY(LiveDeviceName_) next;
48 
49 /** List of the name of devices
50  *
51  * As we don't know the size of the Storage on devices
52  * before the parsing we need to wait and use this list
53  * to create later the LiveDevice via LiveDeviceFinalize()
54  */
55 static TAILQ_HEAD(, LiveDeviceName_) pre_live_devices =
56  TAILQ_HEAD_INITIALIZER(pre_live_devices);
57 
58 typedef struct BypassInfo_ {
59  SC_ATOMIC_DECLARE(uint64_t, ipv4_hash_count);
60  SC_ATOMIC_DECLARE(uint64_t, ipv4_fail);
61  SC_ATOMIC_DECLARE(uint64_t, ipv4_success);
62  SC_ATOMIC_DECLARE(uint64_t, ipv6_hash_count);
63  SC_ATOMIC_DECLARE(uint64_t, ipv6_fail);
64  SC_ATOMIC_DECLARE(uint64_t, ipv6_success);
66 
67 /** if set to 0 when we don't have real devices */
68 static int live_devices_stats = 1;
69 
70 
71 static int LiveSafeDeviceName(const char *devname,
72  char *newdevname, size_t destlen);
73 
74 static int g_live_devices_disable_offloading = 1;
75 
77 {
78  g_live_devices_disable_offloading = 1;
79 }
80 
82 {
83  g_live_devices_disable_offloading = 0;
84 }
85 
86 int LiveGetOffload(void)
87 {
88  return g_live_devices_disable_offloading;
89 }
90 
91 /**
92  * \brief Add a device for monitoring
93  *
94  * To be used during option parsing. When a device has
95  * to be created during runmode init, use LiveRegisterDevice()
96  *
97  * \param dev string with the device name
98  *
99  * \retval 0 on success.
100  * \retval -1 on failure.
101  */
102 int LiveRegisterDeviceName(const char *dev)
103 {
104  LiveDeviceName *pd = NULL;
105 
106  pd = SCCalloc(1, sizeof(LiveDeviceName));
107  if (unlikely(pd == NULL)) {
108  return -1;
109  }
110 
111  pd->dev = SCStrdup(dev);
112  if (unlikely(pd->dev == NULL)) {
113  SCFree(pd);
114  return -1;
115  }
116 
117  TAILQ_INSERT_TAIL(&pre_live_devices, pd, next);
118 
119  SCLogDebug("Device \"%s\" registered.", dev);
120  return 0;
121 }
122 
123 /**
124  * \brief Add a pcap device for monitoring and create structure
125  *
126  * \param dev string with the device name
127  *
128  * \retval 0 on success.
129  * \retval -1 on failure.
130  */
131 int LiveRegisterDevice(const char *dev)
132 {
133  LiveDevice *pd = NULL;
134 
135  pd = SCCalloc(1, sizeof(LiveDevice) + LiveDevStorageSize());
136  if (unlikely(pd == NULL)) {
137  return -1;
138  }
139 
140  int id = LiveGetDeviceCount();
141  if (id > UINT16_MAX) {
142  SCFree(pd);
143  return -1;
144  }
145 
146  pd->dev = SCStrdup(dev);
147  if (unlikely(pd->dev == NULL)) {
148  SCFree(pd);
149  return -1;
150  }
151  /* create a short version to be used in thread names */
152  LiveSafeDeviceName(pd->dev, pd->dev_short, sizeof(pd->dev_short));
153 
154  SC_ATOMIC_INIT(pd->pkts);
155  SC_ATOMIC_INIT(pd->drop);
156  SC_ATOMIC_INIT(pd->invalid_checksums);
157  pd->id = (uint16_t)id;
158  TAILQ_INSERT_TAIL(&live_devices, pd, next);
159 
160  SCLogDebug("Device \"%s\" registered and created.", dev);
161  return 0;
162 }
163 
164 /**
165  * \brief Get the number of registered devices
166  *
167  * \retval cnt the number of registered devices
168  */
170 {
171  int i = 0;
172  LiveDevice *pd;
173 
174  TAILQ_FOREACH(pd, &live_devices, next) {
175  i++;
176  }
177 
178  return i;
179 }
180 
181 /**
182  * \brief Get a pointer to the device name at idx
183  *
184  * \param number idx of the device in our list
185  *
186  * \retval ptr pointer to the string containing the device
187  * \retval NULL on error
188  */
189 const char *LiveGetDeviceName(int number)
190 {
191  int i = 0;
192  LiveDevice *pd;
193 
194  TAILQ_FOREACH(pd, &live_devices, next) {
195  if (i == number) {
196  return pd->dev;
197  }
198 
199  i++;
200  }
201 
202  return NULL;
203 }
204 
205 /** \internal
206  * \brief Shorten a device name that is to long
207  *
208  * \param device name from config and destination for modified
209  *
210  * \retval None, is added to destination char *newdevname
211  */
212 static int LiveSafeDeviceName(const char *devname, char *newdevname, size_t destlen)
213 {
214  const size_t devnamelen = strlen(devname);
215 
216  /* If we have to shorten the interface name */
217  if (devnamelen > MAX_DEVNAME) {
218  /* special mode for DPDK pci addresses */
219  if (devnamelen >= 5 && strncmp(devname, "0000:", 5) == 0) {
220  strlcpy(newdevname, devname + 5, destlen);
221  return 0;
222  }
223 
224  /* IF the dest length is over 10 chars long it will not do any
225  * good for the shortening. The shortening is done due to the
226  * max length of pthread names (15 chars) and we use 3 chars
227  * for the threadname indicator eg. "W#-" and one-two chars for
228  * the thread number. And if the destination buffer is under
229  * 6 chars there is no point in shortening it since we must at
230  * least enter two periods (.) into the string.
231  */
232  if ((destlen-1) > 10 || (destlen-1) < 6) {
233  return 1;
234  }
235 
236  ShortenString(devname, newdevname, destlen, '.');
237 
238  SCLogInfo("%s: shortening device name to %s", devname, newdevname);
239  } else {
240  strlcpy(newdevname, devname, destlen);
241  }
242  return 0;
243 }
244 
245 /**
246  * \brief Get a pointer to the device at idx
247  *
248  * \param number idx of the device in our list
249  *
250  * \retval ptr pointer to the string containing the device
251  * \retval NULL on error
252  */
254 {
255  LiveDevice *pd;
256 
257  if (name == NULL) {
258  SCLogWarning("Name of device should not be null");
259  return NULL;
260  }
261 
262  TAILQ_FOREACH(pd, &live_devices, next) {
263  if (!strcmp(name, pd->dev)) {
264  return pd;
265  }
266  }
267 
268  return NULL;
269 }
270 
271 const char *LiveGetShortName(const char *dev)
272 {
273  LiveDevice *live_dev = LiveGetDevice(dev);
274  if (live_dev == NULL)
275  return NULL;
276  return live_dev->dev_short;
277 }
278 
279 int LiveBuildDeviceList(const char *runmode)
280 {
281  return LiveBuildDeviceListCustom(runmode, "interface");
282 }
283 
284 int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
285 {
286  SCConfNode *base = SCConfGetNode(runmode);
287  SCConfNode *child;
288  int i = 0;
289 
290  if (base == NULL)
291  return 0;
292 
293  TAILQ_FOREACH(child, &base->head, next) {
294  SCConfNode *subchild;
295  TAILQ_FOREACH(subchild, &child->head, next) {
296  if ((!strcmp(subchild->name, itemname))) {
297  if (!strcmp(subchild->val, "default"))
298  break;
299  SCLogConfig("Adding %s %s from config file",
300  itemname, subchild->val);
301  LiveRegisterDeviceName(subchild->val);
302  i++;
303  }
304  }
305  }
306 
307  return i;
308 }
309 
310 /** Call this function to disable stat on live devices
311  *
312  * This can be useful in the case, this is not a real interface.
313  */
315 {
316  live_devices_stats = 0;
317 }
318 
320 {
321  SCEnter();
322  LiveDevice *pd, *tpd;
323 
324  /* dpdk: need to close all devices before freeing them. */
325  TAILQ_FOREACH (pd, &live_devices, next) {
326  DPDKCloseDevice(pd);
327  }
328  TAILQ_FOREACH_SAFE(pd, &live_devices, next, tpd) {
329  if (live_devices_stats) {
330  SCLogNotice("%s: packets: %" PRIu64 ", drops: %" PRIu64
331  " (%.2f%%), invalid chksum: %" PRIu64,
332  pd->dev, SC_ATOMIC_GET(pd->pkts), SC_ATOMIC_GET(pd->drop),
333  SC_ATOMIC_GET(pd->pkts) > 0 ? 100 * ((double)SC_ATOMIC_GET(pd->drop)) /
334  (double)SC_ATOMIC_GET(pd->pkts)
335  : 0,
336  SC_ATOMIC_GET(pd->invalid_checksums));
337  }
338 
340  DPDKFreeDevice(pd);
341 
342  if (pd->dev)
343  SCFree(pd->dev);
344  LiveDevFreeStorage(pd);
345  SCFree(pd);
346  }
347 
349 }
350 
351 #ifdef BUILD_UNIX_SOCKET
352 TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *answer, void *data)
353 {
354  SCEnter();
355  LiveDevice *pd;
356  const char * name = NULL;
357  json_t *jarg = json_object_get(cmd, "iface");
358  if(!json_is_string(jarg)) {
359  json_object_set_new(answer, "message", json_string("Iface is not a string"));
361  }
362  name = json_string_value(jarg);
363  if (name == NULL) {
364  json_object_set_new(answer, "message", json_string("Iface name is NULL"));
366  }
367 
368  TAILQ_FOREACH(pd, &live_devices, next) {
369  if (!strcmp(name, pd->dev)) {
370  json_t *jdata = json_object();
371  if (jdata == NULL) {
372  json_object_set_new(answer, "message",
373  json_string("internal error at json object creation"));
375  }
376  json_object_set_new(jdata, "pkts",
377  json_integer(SC_ATOMIC_GET(pd->pkts)));
378  json_object_set_new(jdata, "invalid-checksums",
379  json_integer(SC_ATOMIC_GET(pd->invalid_checksums)));
380  json_object_set_new(jdata, "drop",
381  json_integer(SC_ATOMIC_GET(pd->drop)));
382  json_object_set_new(jdata, "bypassed",
383  json_integer(SC_ATOMIC_GET(pd->bypassed)));
384  json_object_set_new(answer, "message", jdata);
386  }
387  }
388  json_object_set_new(answer, "message", json_string("Iface does not exist"));
390 }
391 
392 TmEcode LiveDeviceIfaceList(json_t *cmd, json_t *answer, void *data)
393 {
394  SCEnter();
395  json_t *jdata;
396  json_t *jarray;
397  LiveDevice *pd;
398  int i = 0;
399 
400  jdata = json_object();
401  if (jdata == NULL) {
402  json_object_set_new(answer, "message",
403  json_string("internal error at json object creation"));
404  return TM_ECODE_FAILED;
405  }
406  jarray = json_array();
407  if (jarray == NULL) {
408  json_object_set_new(answer, "message",
409  json_string("internal error at json object creation"));
410  return TM_ECODE_FAILED;
411  }
412  TAILQ_FOREACH(pd, &live_devices, next) {
413  json_array_append_new(jarray, json_string(pd->dev));
414  i++;
415  }
416 
417  json_object_set_new(jdata, "count", json_integer(i));
418  json_object_set_new(jdata, "ifaces", jarray);
419  json_object_set_new(answer, "message", jdata);
421 }
422 
423 #endif /* BUILD_UNIX_SOCKET */
424 
426 {
427  if (*ldev == NULL) {
428  *ldev = TAILQ_FIRST(&live_devices);
429  *ndev = TAILQ_NEXT(*ldev, next);
430  return *ldev;
431  } else {
432  *ldev = *ndev;
433  if (*ldev) {
434  *ndev = TAILQ_NEXT(*ldev, next);
435  }
436  return *ldev;
437  }
438  return NULL;
439 }
440 
441 /**
442  * Create registered devices
443  *
444  * This function creates all needed LiveDevice from
445  * the LiveDeviceName list created via LiveRegisterDevice()
446  */
448 {
449  LiveDeviceName *ld, *pld;
450  SCLogDebug("Finalize live device");
451  /* Iter on devices and register them */
452  TAILQ_FOREACH_SAFE(ld, &pre_live_devices, next, pld) {
453  if (ld->dev) {
454  LiveRegisterDevice(ld->dev);
455  SCFree(ld->dev);
456  }
457  SCFree(ld);
458  }
459 }
460 
461 static void LiveDevExtensionFree(void *x)
462 {
463  if (x)
464  SCFree(x);
465 }
466 
467 /**
468  * Register bypass stats storage
469  */
471 {
472  g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", sizeof(void *),
473  NULL, LiveDevExtensionFree);
474 }
475 
476 /**
477  * Prepare a LiveDevice so we can set bypass stats
478  */
480 {
481  BypassInfo *bpinfo = SCCalloc(1, sizeof(*bpinfo));
482  if (bpinfo == NULL) {
483  SCLogError("Can't allocate bypass info structure");
484  return -1;
485  }
486 
487  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
488  SC_ATOMIC_INIT(bpinfo->ipv4_hash_count);
489 
490  LiveDevSetStorageById(dev, g_bypass_storage_id, bpinfo);
491  return 0;
492 }
493 
494 /**
495  * Increase number of currently bypassed flows for a protocol family
496  *
497  * \param dev pointer to LiveDevice to set stats for
498  * \param cnt number of flows to add
499  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
500  */
501 void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
502 {
503  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
504  if (bpfdata) {
505  if (family == AF_INET) {
506  SC_ATOMIC_ADD(bpfdata->ipv4_hash_count, cnt);
507  } else if (family == AF_INET6) {
508  SC_ATOMIC_ADD(bpfdata->ipv6_hash_count, cnt);
509  }
510  }
511 }
512 
513 /**
514  * Decrease number of currently bypassed flows for a protocol family
515  *
516  * \param dev pointer to LiveDevice to set stats for
517  * \param cnt number of flows to remove
518  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
519  */
520 void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
521 {
522  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
523  if (bpfdata) {
524  if (family == AF_INET) {
525  SC_ATOMIC_SUB(bpfdata->ipv4_hash_count, cnt);
526  } else if (family == AF_INET6) {
527  SC_ATOMIC_SUB(bpfdata->ipv6_hash_count, cnt);
528  }
529  }
530 }
531 
532 /**
533  * Increase number of failed captured flows for a protocol family
534  *
535  * \param dev pointer to LiveDevice to set stats for
536  * \param cnt number of flows to add
537  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
538  */
539 void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
540 {
541  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
542  if (bpfdata) {
543  if (family == AF_INET) {
544  SC_ATOMIC_ADD(bpfdata->ipv4_fail, cnt);
545  } else if (family == AF_INET6) {
546  SC_ATOMIC_ADD(bpfdata->ipv6_fail, cnt);
547  }
548  }
549 }
550 
551 /**
552  * Increase number of currently successfully bypassed flows for a protocol family
553  *
554  * \param dev pointer to LiveDevice to set stats for
555  * \param cnt number of flows to add
556  * \param family AF_INET to set IPv4 count or AF_INET6 to set IPv6 count
557  */
558 void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
559 {
560  BypassInfo *bpfdata = LiveDevGetStorageById(dev, g_bypass_storage_id);
561  if (bpfdata) {
562  if (family == AF_INET) {
563  SC_ATOMIC_ADD(bpfdata->ipv4_success, cnt);
564  } else if (family == AF_INET6) {
565  SC_ATOMIC_ADD(bpfdata->ipv6_success, cnt);
566  }
567  }
568 }
569 
570 #ifdef BUILD_UNIX_SOCKET
571 TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data)
572 {
573  if (g_bypass_storage_id.id < 0) {
574  json_object_set_new(answer, "message", json_string("Bypass not enabled"));
576  }
577  LiveDevice *ldev = NULL, *ndev = NULL;
578  json_t *ifaces = NULL;
579  while(LiveDeviceForEach(&ldev, &ndev)) {
580  BypassInfo *bpinfo = LiveDevGetStorageById(ldev, g_bypass_storage_id);
581  if (bpinfo) {
582  uint64_t ipv4_hash_count = SC_ATOMIC_GET(bpinfo->ipv4_hash_count);
583  uint64_t ipv6_hash_count = SC_ATOMIC_GET(bpinfo->ipv6_hash_count);
584  uint64_t ipv4_success = SC_ATOMIC_GET(bpinfo->ipv4_success);
585  uint64_t ipv4_fail = SC_ATOMIC_GET(bpinfo->ipv4_fail);
586  uint64_t ipv6_success = SC_ATOMIC_GET(bpinfo->ipv6_success);
587  uint64_t ipv6_fail = SC_ATOMIC_GET(bpinfo->ipv6_fail);
588  json_t *iface = json_object();
589  if (ifaces == NULL) {
590  ifaces = json_object();
591  if (ifaces == NULL) {
592  json_object_set_new(answer, "message",
593  json_string("internal error at json object creation"));
594  return TM_ECODE_FAILED;
595  }
596  }
597  json_object_set_new(iface, "ipv4_maps_count", json_integer(ipv4_hash_count));
598  json_object_set_new(iface, "ipv4_success", json_integer(ipv4_success));
599  json_object_set_new(iface, "ipv4_fail", json_integer(ipv4_fail));
600  json_object_set_new(iface, "ipv6_maps_count", json_integer(ipv6_hash_count));
601  json_object_set_new(iface, "ipv6_success", json_integer(ipv6_success));
602  json_object_set_new(iface, "ipv6_fail", json_integer(ipv6_fail));
603  json_object_set_new(ifaces, ldev->dev, iface);
604  }
605  }
606  if (ifaces) {
607  json_object_set_new(answer, "message", ifaces);
609  }
610 
611  json_object_set_new(answer, "message",
612  json_string("No interface using bypass"));
614 }
615 #endif
616 
618 {
619  return SC_ATOMIC_GET(dev->pkts);
620 }
621 
623 {
624  (void)SC_ATOMIC_ADD(dev->pkts, 1);
625 }
626 
627 void LiveDevicePktsAdd(LiveDevice *dev, uint64_t n)
628 {
629  (void)SC_ATOMIC_ADD(dev->pkts, n);
630 }
631 
632 void LiveDeviceDropAdd(LiveDevice *dev, uint64_t n)
633 {
634  (void)SC_ATOMIC_ADD(dev->drop, n);
635 }
636 
637 void LiveDeviceBypassedAdd(LiveDevice *dev, uint64_t n)
638 {
639  (void)SC_ATOMIC_ADD(dev->bypassed, n);
640 }
641 
643 {
644  return SC_ATOMIC_GET(dev->invalid_checksums);
645 }
util-device-private.h
LiveRegisterDevice
int LiveRegisterDevice(const char *dev)
Add a pcap device for monitoring and create structure.
Definition: util-device.c:131
LiveDeviceListClean
int LiveDeviceListClean(void)
Definition: util-device.c:319
LiveGetShortName
const char * LiveGetShortName(const char *dev)
Definition: util-device.c:271
SC_ATOMIC_INIT
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
Definition: util-atomic.h:314
LiveDevStorageId_
Definition: device-storage.h:31
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
LiveDevFreeStorage
void LiveDevFreeStorage(LiveDevice *d)
Definition: device-storage.c:101
LiveDevRegisterExtension
void LiveDevRegisterExtension(void)
Definition: util-device.c:470
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
LiveGetOffload
int LiveGetOffload(void)
Definition: util-device.c:86
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
LiveBuildDeviceList
int LiveBuildDeviceList(const char *runmode)
Definition: util-device.c:279
LiveDevice_
Definition: util-device-private.h:32
SC_ATOMIC_ADD
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
Definition: util-atomic.h:332
LiveDevice_::id
uint16_t id
Definition: util-device-private.h:38
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:252
LiveDeviceForEach
LiveDevice * LiveDeviceForEach(LiveDevice **ldev, LiveDevice **ndev)
Definition: util-device.c:425
device-storage.h
LiveDeviceHasNoStats
void LiveDeviceHasNoStats(void)
Definition: util-device.c:314
TAILQ_INSERT_TAIL
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:294
LiveDevicePktsAdd
void LiveDevicePktsAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:627
LiveDevSubBypassStats
void LiveDevSubBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:520
LiveDevicePktsGet
uint64_t LiveDevicePktsGet(LiveDevice *dev)
Definition: util-device.c:617
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:82
ShortenString
void ShortenString(const char *input, char *output, size_t output_size, char c)
Definition: util-misc.c:207
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:81
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
TAILQ_ENTRY
#define TAILQ_ENTRY(type)
Definition: queue.h:239
LiveDevGetStorageById
void * LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id)
Get a value from a given LiveDevice storage.
Definition: device-storage.c:90
LiveDevStorageRegister
LiveDevStorageId LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *))
Register a LiveDevice storage.
Definition: device-storage.c:61
TAILQ_HEAD_INITIALIZER
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:236
util-debug.h
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:250
LiveSetOffloadDisable
void LiveSetOffloadDisable(void)
Definition: util-device.c:76
LiveBuildDeviceListCustom
int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
Definition: util-device.c:284
LiveGetDevice
LiveDevice * LiveGetDevice(const char *name)
Get a pointer to the device at idx.
Definition: util-device.c:253
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
LiveDeviceName
LiveDeviceName
Definition: util-device.c:47
RestoreIfaceOffloading
void RestoreIfaceOffloading(LiveDevice *dev)
Definition: util-ioctl.c:697
LiveDevice_::dev
char * dev
Definition: util-device-private.h:33
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:249
LiveDeviceInvalidChecksumsGet
uint64_t LiveDeviceInvalidChecksumsGet(LiveDevice *dev)
Definition: util-device.c:642
DPDKFreeDevice
void DPDKFreeDevice(LiveDevice *ldev)
Definition: util-dpdk.c:59
SC_ATOMIC_SUB
#define SC_ATOMIC_SUB(name, val)
sub a value from our atomic variable
Definition: util-atomic.h:341
SC_ATOMIC_DECLARE
#define SC_ATOMIC_DECLARE(type, name)
wrapper for declaring atomic variables.
Definition: util-atomic.h:280
LiveDeviceDropAdd
void LiveDeviceDropAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:632
conf.h
LiveDevUseBypass
int LiveDevUseBypass(LiveDevice *dev)
Definition: util-device.c:479
TmEcode
TmEcode
Definition: tm-threads-common.h:80
name
const char * name
Definition: tm-threads.c:2123
LiveDevAddBypassStats
void LiveDevAddBypassStats(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:501
LiveDevAddBypassSuccess
void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:558
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:224
TAILQ_FOREACH_SAFE
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:329
DPDKCloseDevice
void DPDKCloseDevice(LiveDevice *ldev)
Definition: util-dpdk.c:41
cnt
uint32_t cnt
Definition: tmqh-packetpool.h:7
util-dpdk.h
suricata-common.h
LiveGetDeviceName
const char * LiveGetDeviceName(int number)
Get a pointer to the device name at idx.
Definition: util-device.c:189
TAILQ_NEXT
#define TAILQ_NEXT(elm, field)
Definition: queue.h:307
LiveSetOffloadWarn
void LiveSetOffloadWarn(void)
Definition: util-device.c:81
SCStrdup
#define SCStrdup(s)
Definition: util-mem.h:56
LiveDevAddBypassFail
void LiveDevAddBypassFail(LiveDevice *dev, uint64_t cnt, int family)
Definition: util-device.c:539
LiveDeviceBypassedAdd
void LiveDeviceBypassedAdd(LiveDevice *dev, uint64_t n)
Definition: util-device.c:637
SCLogConfig
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
SCConfGetNode
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
Definition: conf.c:181
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
MAX_DEVNAME
#define MAX_DEVNAME
Definition: util-device.c:28
util-ioctl.h
LiveDevStorageSize
unsigned int LiveDevStorageSize(void)
Definition: device-storage.c:32
TAILQ_HEAD
#define TAILQ_HEAD(name, type)
Definition: queue.h:230
LiveDevSetStorageById
int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr)
Store a pointer in a given LiveDevice storage.
Definition: device-storage.c:77
SCConfNode_::name
char * name
Definition: conf.h:38
LiveGetDeviceCount
int LiveGetDeviceCount(void)
Get the number of registered devices.
Definition: util-device.c:169
LiveRegisterDeviceName
int LiveRegisterDeviceName(const char *dev)
Add a device for monitoring.
Definition: util-device.c:102
LiveDeviceFinalize
void LiveDeviceFinalize(void)
Definition: util-device.c:447
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:375
LiveDevice_::dev_short
char dev_short[MAX_DEVNAME+1]
Definition: util-device-private.h:34
util-misc.h
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:237
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
LiveDevStorageId_::id
int id
Definition: device-storage.h:32
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
SCConfNode_
Definition: conf.h:37
SCConfNode_::val
char * val
Definition: conf.h:39
BypassInfo
BypassInfo
Definition: util-device.c:65
LiveDevicePktsIncr
void LiveDevicePktsIncr(LiveDevice *dev)
Definition: util-device.c:622