pcap-file: limit setvbuf to linux

As it fails to work correctly on FreeBSD and OpenBSD.

On FreeBSD, these are the errors:

Info: pcap: Pcap-file will use 4096 buffer size [PcapFileGlobalInit:source-pcap-file.c:159]
Error: pcap: failed to get first packet timestamp. pcap_next_ex(): -2 [PeekFirstPacketTimestamp:source-pcap-file-helper.c:186]
Warning: pcap: Failed to init pcap file input.pcap, skipping [ReceivePcapFileThreadInit:source-pcap-file.c:299]
Error: pcap: pcap file reader thread failed to initialize [ReceivePcapFileLoop:source-pcap-file.c:185]
pull/11683/head
Victor Julien 1 year ago committed by Victor Julien
parent 688bd538cf
commit cff82f16b3

@ -274,7 +274,7 @@
;;
*-*-linux*)
# Always compile with -fPIC on Linux for shared library support.
CFLAGS="${CFLAGS} -fPIC"
CFLAGS="${CFLAGS} -fPIC -DOS_LINUX"
RUST_LDADD="-ldl -lrt -lm"
can_build_shared_library="yes"
AC_DEFINE([SYSTEMD_NOTIFY], [1], [make Suricata notify systemd on startup])

@ -208,7 +208,7 @@ TmEcode InitPcapFile(PcapFileFileVars *pfv)
SCReturnInt(TM_ECODE_FAILED);
}
#if defined(HAVE_SETVBUF) && !defined(OS_WIN32)
#if defined(HAVE_SETVBUF) && defined(OS_LINUX)
if (pcap_g.read_buffer_size > 0) {
errno = 0;
if (setvbuf(pcap_file(pfv->pcap_handle), pfv->buffer, _IOFBF, pcap_g.read_buffer_size) <

@ -84,7 +84,7 @@ typedef struct PcapFileFileVars_
/** flex array member for the libc io read buffer. Size controlled by
* PcapFileGlobalVars::read_buffer_size. */
#if defined(HAVE_SETVBUF) && !defined(OS_WIN32)
#if defined(HAVE_SETVBUF) && defined(OS_LINUX)
char buffer[];
#endif
} PcapFileFileVars;

@ -146,7 +146,7 @@ void PcapFileGlobalInit(void)
memset(&pcap_g, 0x00, sizeof(pcap_g));
SC_ATOMIC_INIT(pcap_g.invalid_checksums);
#if defined(HAVE_SETVBUF) && !defined(OS_WIN32)
#if defined(HAVE_SETVBUF) && defined(OS_LINUX)
pcap_g.read_buffer_size = PCAP_FILE_BUFFER_SIZE_DEFAULT;
const char *str = NULL;

Loading…
Cancel
Save