Commit Graph

43 Commits (51ab06256a50f8e7143cc7bfd4807a59ac66dfaa)

Author SHA1 Message Date
Eric Leblond 4e6add7faa bypass: generalize iface bypass stats
Introduce functions in util-device.c to be able to manage the
flow bypassed count stats.
6 years ago
Victor Julien 12fec46d13 multi-tenant: introduce device selector
Add device to tenant mapping support:

  mappings:
  - device: ens5f0
    tenant-id: 1
  - device: ens5f1
    tenant-id: 23

Implemented by assigning the tenant id to the 'livedev', which means
it's only supported for capture methods that use the livedev API.

It's also currently not supported for IPS. In a case like 'eth0 -> eth1'
it's unclear which tenant should be used for the return traffic in a
flow, where the incoming device is 'eth1'.
7 years ago
Eric Leblond 0356293d84 unix-socket: add bypassed counter to iface-stat 7 years ago
Eric Leblond 4474889667 util-device: change logic of registration
Device storage requires the devices to be created after storage
is finalized so we need to first get the list of devices then
create them when the storage is finalized.

This patch introduces the LiveDeviceName structure that is a list
of device name used during registration.

Code uses LiveRegisterDeviceName for pre registration and keep
using the LiveRegisterDevice function for part of the code that
create the interface during the runmode creation.
7 years ago
Eric Leblond 0998f37b78 util-device: add an iteration function 7 years ago
Eric Leblond 3ae714d354 device-storage: introduce feature
The capture method may have to store data depending related to the
offloading so having a per interface storage via LiveDevice seems
interesting.
7 years ago
Victor Julien ec964ebf84 mingw: don't use uint type as mingw doesn't have it 8 years ago
Victor Julien 499e27de14 offloading: restore settings on exit 9 years ago
Victor Julien 2780fba1d1 device: add global flag for disabling offloading
Add global flag to disable offloading or just warn on it.
9 years ago
Victor Julien 5c974f92a8 livedev: shorten devname at registration 9 years ago
Victor Julien 2aac437927 output: reduce verbosity on info level 9 years ago
Victor Julien db4ec46f18 coverty: fix dead code warning 9 years ago
Zachary Rasmor 885747218b Update shortening algorithm to account for addition of #. 9 years ago
maxtors a17ac21077 Reworked how shortening should be performed.
The shortening of the interfacenames is now dependent on the
size of the destination buffer, so that this can be easily
changed in the future. The process uses snprintf and strlcat.

Also changed the buffer sizes in the util-runmodes to 12
so that they can hold 11 chars + null terminator.
9 years ago
maxtors 88a6e79607 Fixed string copy and cat functions and made shortening safer.
Changed out strcpy, strncpy to strlcat and strlcpy. Also added
checks to see if the shortening did work or if it would fail in
advance. Fixed code in util-device and util-runmodes.
9 years ago
maxtors 10d1450e49 Added shortening of listening interface in util-runmodes
Added function LiveSafeDeviceName in util-device that shortens an
NIC device name if the name is over a given length and turns
it in to Ex: longi...eeth1
9 years ago
Eric Leblond 606ac17c57 util: get rid of json_array_append
This function is causing a memleak because it is necessary to clean
up after usage.

This fixes at least:

37 (32 direct, 5 indirect) bytes in 1 blocks are definitely lost in loss record 104 of 394
   at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x66D0C7B: ??? (in /usr/lib/x86_64-linux-gnu/libjansson.so.4.7.0)
   by 0x943584: LiveDeviceIfaceList (util-device.c:264)
   by 0x910889: UnixCommandExecute (unix-manager.c:486)
   by 0x910D7E: UnixCommandRun (unix-manager.c:545)
   by 0x911193: UnixMain (unix-manager.c:593)
   by 0x913CC7: UnixManager (unix-manager.c:961)
   by 0x907753: TmThreadsManagement (tm-threads.c:600)
   by 0x68DE283: start_thread (pthread_create.c:333)
   by 0x80A6A4C: clone (in /lib/x86_64-linux-gnu/libc-2.21.so)
9 years ago
Victor Julien 7b45a8a2a9 device: constify string args 9 years ago
Eric Leblond 43f691fef8 util-device: fix LiveBuildDeviceListCustom
The code was assuming that the dictionnary containing the parameter
of a interface was ordered. But for YAML, the order is not assumed
so in case the configuration is generated we may not be able to
parse correctly the configuration file.

By iterating on child on main node and then iterating on subchild
and doing a match on the name, we are able to find the interface
list. In term of code, this algorithm was obtained by simply
removing the test on the name of the first child.
10 years ago
Ken Steele 8f1d75039a Enforce function coding standard
Functions should be defined as:

int foo(void)
{
}

Rather than:
int food(void) {
}

All functions where changed by a script to match this standard.
11 years ago
Giuseppe Longo 0368d5e4a4 Declare a wrapper to parse group option for nflog 11 years ago
Eric Leblond 6b2ca63d9d util-device: add function to avoid stat display
In the case of running mode like NFQ there is no need possibility
to compute the statistics as it is done in LiveDevice (drop and
checksum count are meaningless).

This patch adds a function that allow running mode to disable the
display of the counters at exit.
11 years ago
Eric Leblond a12c46c700 util-device: fix debug message
Reference to Pcap was not correct.
11 years ago
Eric Leblond 3ce39433dd capture: use 64 bits counters
Some of the packets counters were using a 32bit integer. Given the
bandwidth that is often seen, this is not a good idea. This patch
switches to 64bit counter.
11 years ago
Eric Leblond 7d104fde1d util-device: use safe tailq foreach
The loop is freeing elements so we need to use the safe version
of TIALQ_FOREACH.

This fixes a valgrind error:

 Thread 1 Suricata-Main:
 Invalid read of size 8
    at 0x8E129C: LiveDeviceListClean (util-device.c:167)
    by 0x89B742: main (suricata.c:2284)
  Address 0x8382988 is 24 bytes inside a block of size 40 free'd
    at 0x4C2A70C: free (vg_replace_malloc.c:468)
    by 0x8E1297: LiveDeviceListClean (util-device.c:179)
    by 0x89B742: main (suricata.c:2284)
11 years ago
Eric Leblond a8c787a265 device list: clean and display stat at exit
This patch adds a cleaning function to device list. This also
permits to display per-interface statistics during the exit.
11 years ago
Eric Leblond 28c5c68192 error checking: add missing alloc error treatment
The return of some malloc like functions was not treated in some
places of the code.
11 years ago
Eric Leblond 26b7af1483 Don't try to sniff 'default' interface
Whan running suricata via 'suricata --af-packet', the list of interfaces
was containing the 'default' interface and sniffing it was attempted.
This was not wanted.
12 years ago
Victor Julien 0f42f0e890 Minor fixes 12 years ago
Eric Leblond af16c418b7 unix-socket: fix build when jansson not present 12 years ago
Eric Leblond ef64648cf8 unix-command: add drop counter to iface-stat message 12 years ago
Eric Leblond 8d0260b27e Add atomic counter for iface drop. 12 years ago
Eric Leblond cc71c993f4 unix-command: add iface information command.
This patch adds two commands to unix-command. 'iface-list' displays
the list of interface which are sniffed by Suricata and 'iface-stat'
display the available statistics for a single interface. For now,
this is the number of packets and the number of invalid checksums.
12 years ago
Eric Leblond e176be6fcc Use unlikely for error treatment.
When handling error case on SCMallog, SCCalloc or SCStrdup
we are in an unlikely case. This patch adds the unlikely()
expression to indicate this to gcc.

This patch has been obtained via coccinelle. The transformation
is the following:

@istested@
identifier x;
statement S1;
identifier func =~ "(SCMalloc|SCStrdup|SCCalloc)";
@@

x = func(...)
... when != x
- if (x == NULL) S1
+ if (unlikely(x == NULL)) S1
13 years ago
Victor Julien cdba2f50d1 Various fixes and improvements based on feedback by Coverity analyzer. 13 years ago
Victor Julien d24b3a0e50 Clean up csum detection output, misc fixes. 13 years ago
Eric Leblond c3eaa6cc60 Add per-interface counter for invalid checksum.
This patch adds a per-device counter for invalid checksum as
well as a simple packet counter.
13 years ago
Eric Leblond 745b61171a Introduce LiveGetDevice function 13 years ago
Eric Leblond e893e860d4 Rename LiveGetDevice to LiveGetDeviceName
The function LiveGetDevice is returning a point to
the name of the interface. This patch renames it to
LiveGetDeviceName which is more appropriate.
13 years ago
Eric Leblond 5cfdd7594f util-device: Modify function name.
This patch modifies LiveBuildQueueList name to LiveBuildDeviceList
to have a consistent naming accross function. It also adds a
doxygen comment to add author and description of util-device.c
file.
13 years ago
Eric Leblond e253da092c device: Add function to build interface list from config
This patch adds a new function which build the list of interfaces to
use by parsing the configuration file. This is using the new format
and thus only af-packet can benefit of this feature.
14 years ago
Eric Leblond e80b30c082 af-packet: finalize code
This patch handles the end of AF_PACKET socket support work. It
provides conditional compilation, autofp and single runmode.

It also adds a 'defrag' option which is used to activate defrag
support in kernel to avoid rx_hash computation in flow mode to fail
due to fragmentation.

This patch contains some fixes by Anoop Saldanha, and incorporate
change following review by Anoop Saldanha and Victor Julien.

AF_PACKET support is only build if the --enable-af-packet flag is
given to the configure command line. Detection of code availability
is also done: a check of the existence of AF_PACKET in standard
header is done. It seems this variable is Linux specific and it
should be enough to avoid compilation of AF_PACKET support on other
OSes.
Compilation does not depend on up-to-date headers on the system. If
none are present, wemake our own declaration of FANOUT variables. This
will permit compilation of the feature for system where only the kernel
has been updated to a version superior to 3.1.
14 years ago
Eric Leblond 871b21892a factorize pcap live device function
They are not specific to pcap and could thus be used in other module.
14 years ago