]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix pcap packet acquisition methods
authorVictor Julien <victor@inliniac.net>
Fri, 25 Jul 2014 11:47:59 +0000 (13:47 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 25 Jul 2014 11:47:59 +0000 (13:47 +0200)
Fix pcap packet acquisition methods passing 0 to pcap_dispatch.
Previously they passed the packet pool size, but the packet_q_len
variable was now hardcoded at 0.

This patch sets packet_q_len to 64. If packet pool is empty, we fall
back to direct alloc. As the pcap_dispatch function is only called
when packet pool is not empty, we alloc at most 63 packets.

src/source-pcap-file.c
src/source-pcap.c

index 0d6f9a74ed87594827e0446b26ec89bb383685b3..da0f6ee35cae5635ecf6eb9ed396f63a0bc9758f 100644 (file)
@@ -185,7 +185,7 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
 {
     SCEnter();
 
-    uint16_t packet_q_len = 0;
+    int packet_q_len = 64;
     PcapFileThreadVars *ptv = (PcapFileThreadVars *)data;
     int r;
     TmSlot *s = (TmSlot *)slot;
@@ -203,7 +203,7 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
         PacketPoolWait();
 
         /* Right now we just support reading packets one at a time. */
-        r = pcap_dispatch(pcap_g.pcap_handle, (int)packet_q_len,
+        r = pcap_dispatch(pcap_g.pcap_handle, packet_q_len,
                           (pcap_handler)PcapFileCallbackLoop, (u_char *)ptv);
         if (unlikely(r == -1)) {
             SCLogError(SC_ERR_PCAP_DISPATCH, "error code %" PRId32 " %s",
index f116da3fbefdfc1849b1c3c4e91154c3adbbf1e1..e7c40d2f20dfbe0fd6c588c8fae168deaa91ebcb 100644 (file)
@@ -294,7 +294,7 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot)
 {
     SCEnter();
 
-    uint16_t packet_q_len = 0;
+    int packet_q_len = 64;
     PcapThreadVars *ptv = (PcapThreadVars *)data;
     int r;
     TmSlot *s = (TmSlot *)slot;
@@ -312,7 +312,7 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot)
         PacketPoolWait();
 
         /* Right now we just support reading packets one at a time. */
-        r = pcap_dispatch(ptv->pcap_handle, (int)packet_q_len,
+        r = pcap_dispatch(ptv->pcap_handle, packet_q_len,
                           (pcap_handler)PcapCallbackLoop, (u_char *)ptv);
         if (unlikely(r < 0)) {
             int dbreak = 0;