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