]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: implement rollover option
authorEric Leblond <eric@regit.org>
Fri, 19 Jun 2015 10:13:31 +0000 (12:13 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 21 Jul 2015 21:37:34 +0000 (23:37 +0200)
This patch implements the rollover option in af_packet capture.
This should heavily minimize the packet drops as well as the
maximum bandwidth treated for a single flow.

The option has been deactivated by default but it is activated in
the af_packet default section. This ensure there is no change for
old users using an existing YAML. And new users will benefit from
the change.

This option is available since Linux 3.10. An analysis of af_packet
kernel code shows that setting the flag in all cases should not
cause any trouble for older kernel.

src/runmode-af-packet.c
suricata.yaml.in

index cd2b5266b7eaa36067db1bef953dcf52900967ee..fc17a4bd6669706fdd76c56263f20458bb5d578f 100644 (file)
@@ -301,6 +301,14 @@ void *ParseAFPConfig(const char *iface)
         return NULL;
     }
 
+    int conf_val = 0;
+    ConfGetChildValueBoolWithDefault(if_root, if_default, "rollover", &conf_val);
+    if (conf_val) {
+        SCLogInfo("Using rollover kernel functionality for AF_PACKET (iface %s)",
+                aconf->iface);
+        aconf->cluster_type |= PACKET_FANOUT_FLAG_ROLLOVER;
+    }
+
     /*load af_packet bpf filter*/
     /* command line value has precedence */
     if (ConfGet("bpf-filter", &bpf_filter) != 1) {
index 480521a42b69aa3db0d6f6274ca113ef9f22ab7a..da1ee3a9cc1bd2cf318944736c3c886d3fccf4ad 100644 (file)
@@ -428,6 +428,10 @@ af-packet:
     # In some fragmentation case, the hash can not be computed. If "defrag" is set
     # to yes, the kernel will do the needed defragmentation before sending the packets.
     defrag: yes
+    # After Linux kernel 3.10 it is possible to activate the rollover option: if a socket is
+    # full then kernel will send the packet on the next socket with room available. This option
+    # can minimize packet drop and increase the treated bandwith on single intensive flow.
+    #rollover: yes
     # To use the ring feature of AF_PACKET, set 'use-mmap' to yes
     use-mmap: yes
     # Ring size will be computed with respect to max_pending_packets and number
@@ -474,6 +478,7 @@ af-packet:
   - interface: default
     #threads: auto
     #use-mmap: yes
+    rollover: yes
 
 # Netmap support
 #