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