]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pcap-file: limit setvbuf to linux
authorVictor Julien <vjulien@oisf.net>
Fri, 12 Jul 2024 08:34:42 +0000 (10:34 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 30 Aug 2024 13:18:59 +0000 (15:18 +0200)
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]

configure.ac
src/source-pcap-file-helper.c
src/source-pcap-file-helper.h
src/source-pcap-file.c

index 1bdf823506e6baef4961a7028848f43ac645d453..24dc01430a358c2f1a68683b7ed3d78da790cc7e 100644 (file)
             ;;
         *-*-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])
index c7303fa3995097eb85329cedaa7377e0d7b4b123..1c9f5933ba910a6b44f7faa9c00d6699d4b9262f 100644 (file)
@@ -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) <
index 3068c14e3cf67ad36b37aa76e281e31a26bdabf0..2de7d16cc3727574e0fb24b47d03862cf8e9e15c 100644 (file)
@@ -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;
index 85f992d5ca960db0bf29c868611224fc77143a0d..4492f4698e6aeea7b16cf3a15b96e20619c461eb 100644 (file)
@@ -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;