Commit Graph

306 Commits (f553fbdab434bc7ea67b9054fd714f9624e9f0a1)

Author SHA1 Message Date
Philippe Antoine dc29ab46ed ebpf: check maps compatibility
ebpf program does not handle 3 layers of vlan
8 months ago
Philippe Antoine dd6baccabd src: doc: remove more double-space typos
Found with git grep -E '[a-z]  [a-z]'
10 months ago
Victor Julien 365ed2a2ff af-packet: disable hwtimestamp by default
Add enable-hwtimestamp option to replace disable-hwtimestamp.

Ticket: #7585.
11 months ago
Victor Julien 18a6a079da af-packet: add disable-hwtimestamp option
HW timestamping is not always reliable, so add an option to disable it.

Bug: #1954.
11 months ago
Victor Julien 7c0776abeb counters: remove ThreadVars from counter registration
Just pass the StatsThreadContext pointer directly.
11 months ago
Victor Julien 77ddbbb9c8 counters: regular counter get local API update 11 months ago
Victor Julien 78da4cfcae counters: regular counter Incr API update 11 months ago
Victor Julien dfbfc81c51 counters: regular counter Add API update 11 months ago
Victor Julien adebfcd4a5 counters: remove ThreadVars from Avg counter API 11 months ago
Victor Julien c27d0b4192 counters: remove ThreadVars from sync API 11 months ago
Victor Julien 444166ec84 counters: move regular counter id to dedicated type 11 months ago
Victor Julien a8095d8ef5 counters: use a dedicated type for avg counters 11 months ago
Philippe Antoine 9e64555c5e util: fix -Wshorten-64-to-32 warnings for afpacket
Ticket: #6186
1 year ago
Jason Ish 9d5158594f util-device: break into public and private definitions
util-device.h exposes some details that are particularly problematic
for C++, even when wrapped in 'extern "C"'. To address this, break the
header into public and private parts. The public part exposes
LiveDevice as an opaque data structure, while the private header has
the actual definition.

The idea is that only Suricata C source files should include the
private header, it should not be re-included in any other header
file. And this is the header library users should use, however we
don't enforce it with tecnical means, a library user could still
include the private header, but the clue there is in the name.
2 years ago
Jason Ish 51f7b5924d af-packet: remove build conditional for tpacket-v3
All kernels on supported distrubtions should now support tpacket-v3,
so only enable af-packet if v2 and v3 are available.
2 years ago
Victor Julien 749ffbd06a af-packet: use actual snaplen in bpf
Avoids setting a 0 snaplen in BPF, leading to an error.

Fixes: b8b6ed550a ("af-packet: delay setting default-packet-size for af-packet")

Ticket: #7618.
2 years ago
Jason Ish b8b6ed550a af-packet: delay setting default-packet-size for af-packet
AF_PACKET needs more information about its configuration before we can
set the default packet size, so on startup, leave unset in suricata.c
if in AF_PACKET mode.

If defrag is enabled, use a default packet size of 9k for tpacket-v2.
This can still lead to truncation events, then the user can increase
their 'default-packet-size'.

Tpacket-v3 does not need an increased packet size as it will handle
any size of packet that is smaller than the configured block size
which now has a default of 128k.

9k for the snap is somewhat arbitrary but is large enough for the
common 9000 jumbo frame plus some extra headers including tpacket
headers.

Ticket: #7458
2 years ago
Jason Ish d78f2c9a4e af-packet: add event for packets truncated by af-packet
Ticket: #7458
2 years ago
Jason Ish 5871c6458c af-packet: make tpacket-v2 block size configurable
With the change of the default tpacket-v2 block size from 32k to 128k,
allow it to be configurable for users who may want to make it larger,
or revert it back to the pre 7.0.9 default of 32k.

Ticket: #7458
2 years ago
Jeff Lucovsky 7d5c170dd2 gen/bool: Clarify bool checks
Remove comparisons with true or false with C bools.
2 years ago
Eric Leblond 22a71e7317 af-packet: code cleaning
clang-tidy did detect the -1 return value was not compatible with
TmEcode enum.
2 years ago
Victor Julien 923ad6af77 af-packet: speed up thread sync during startup
Threads are initialized sequentially to allow for a predictable mapping
of threads and queues. Not all parts of the start up need to be done
sequentially. The setting up of the rings can be very expensive, taking
of a couple of hundred milliseconds. The ring setup doesn't need to be
done sequentially though.

This patch releases the thread early, after bind but before the ring
setups.

Ticket: #7272.
2 years ago
Victor Julien 96a0ffadde packetpool: allow larger max-pending-packets
Original limit was due to a specific data structure.
2 years ago
Jeff Lucovsky 834cd6fbdb af-packet: Remove unused preprocessor define
Remove unused preprocessor value; exposed by compilation warning
2 years ago
Philippe Antoine ce9bfba76a ci: fix and test with Wunused-macros
Ticket: 6937
2 years ago
Victor Julien 8698610b4a af-packet: fix eBPF/XDP compilation 3 years ago
Victor Julien 54362d44db decode/ethernet: move ethh into L2 section
L2 section similar to L3 and L4 sections.

Ticket: #6938.
3 years ago
Victor Julien 5c3036bea8 decode/udp: add and use PacketIsUDP inline func
Replace PKT_IS_UDP macro with PacketIsUDP inline function.

For better readability and type checking.

Ticket: #5517.
3 years ago
Victor Julien cca912e9b3 decode/tcp: add and use PacketIsTCP inline func
To prepare future changes to the Packet header pointers.

Ticket: #5517.
3 years ago
Victor Julien eb3ca643c1 decode: reduce PKT_IS_IPV4/PKT_IS_IPV6 use
Replace it with inline functions. Adds inline functions to
wrap PKT_IS_IPV4/PKT_IS_IPV6.

This is in preparation of removing the macro's, and cleaning up the
header pointers.

Ticket: #5517.
3 years ago
Victor Julien 6066c4d6e7 decode/tunnel: improve tunnel handling
Give each packet explicit tunnel type `ttype`: none, root, child.

Assigning happens when a (tunnel) packet is set up and is thread
safe.
3 years ago
Jeff Lucovsky 193e0ea1a9 memory/alloc: Use SCCalloc instead of malloc/memset 3 years ago
Shivani Bhardwaj 2fa0fac289 af-packet: fetch mtu info once
With the current layout and fn calls, it was seen that once in the
beginning after the MTU was found and displayed to the user, when the
threads spawned, each thread displayed MTU info as a part of
AFPPeersListAdd fn. This happened in AF_PACKET IPS mode and led to
excessive MTU logs.
Save this info in the LiveDevice struct and avoid calling the unneeded
fns later on.

Bug 5831
3 years ago
Shivani Bhardwaj 572f8a3da6 util/ioctl: use LiveDevice to retrieve name
The fn GetIfaceMaxPacketSize now uses LiveDevice object as a param
instead of a string. This was done to keep the logic of checking for the
device to this function itself instead of having callers first determine
whether the device exists or not.
This also falls in line with the changes made to avoid excessive MTU
logs in the following commit.

Related to redmine ticket 5831.
3 years ago
Jeff Lucovsky 0d2268ddfc decode/vlan: Decode upto 3 layers of VLAN
Issue: 2816

This commit increase the number of VLAN layers supported by Suricata
from 2 to 3. 3-layers are dubbed "Q-in-Q-in-Q".

Note that 3 layers are not compliant with any existing standard but are
often seen in larger deployments.
3 years ago
Victor Julien 8dc58a6e9d capture: spelling 4 years ago
Jason Ish b5fbdc3e5f capture: use uint16_t for max_pending_packets
Use a fixed type of max_pending_packets instead of intmax_t which can
differ based on the platform/standard library.

Should also prevent lints about possible arithmetic overflow.
4 years ago
Arne Welzel 51aef3c230 af-packet: Ignore outgoing packets on loopback interfaces
When reading a loopback interface, packets are received twice: Once as
outgoing packets and once as incoming packets.

Libpcap ignores outgoing packets. With current versions of Suricata, sniffing
a single http://localhost:80 request over lo using the af-packet source
minimally shows two syn packets, two synacks and twice as many packets in
the stats entries than you'd expect when running tcpdump or Wireshark.
4 years ago
Victor Julien 0265c13550 src: fix extern max_pending_packets type 4 years ago
Jeff Lucovsky 9fbe683642 time: Rework SCTime_t into a struct
Issue: 5718

This commit changes SCTime_t to a struct with members setup as
bitfields.
4 years ago
Jeff Lucovsky 31793aface time: Replace struct timeval with scalar value
Issue: 5718

This commit switches the majority of time handling to a new type --
SCTime_t -- which is a 64 bit container for time:
- 44 bits -- seconds
- 20 bits -- useconds
4 years ago
Victor Julien ebd8728219 src: fix strict-prototype warnings
Tested on Fedora 37 with clang 15.

app-layer.c:1055:27: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
void AppLayerSetupCounters()
                          ^
                           void
app-layer.c:1176:29: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
void AppLayerDeSetupCounters()
                            ^
                             void
2 errors generated.
4 years ago
Victor Julien 8b846bdcff af-packet: output cleanups and unification
Make all messages use the same format:

<iface>: <message>
4 years ago
Victor Julien b31ffde6f4 output: remove error codes from output 4 years ago
Victor Julien 39f5c7f56a error: use SC_EINVAL for invalid input 4 years ago
Victor Julien e042cd785e error: use SC_ENOMEM for alloc errors 4 years ago
Victor Julien ef881c942b af-packet: output cleanups 4 years ago
Philippe Antoine ad713246a9 src: remove double includes
Keep the unconditional include to be sure it works

git grep '#include "' src/*.c | sort | uniq -c | awk '$1 > 1'
4 years ago
Philippe Antoine 62352ad030 src: fix remaining cppclean warnings 4 years ago
Philippe Antoine e85f3916e3 src: fix integer warnings
and adds defrag debug validations
4 years ago