]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pfring pkt acq: keep running on 'pfring_set_cluster' failure when cluster is not...
authorcardigliano <cardigliano@ntop.org>
Thu, 22 Oct 2015 09:55:57 +0000 (11:55 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Nov 2015 12:58:07 +0000 (13:58 +0100)
Suricata creates a pfring cluster with a default ID = 1 when not explicitly configured,
unless the device has prefix 'dna' or 'zc'. Since pf_ring also supports other cards
implementing kernel-bypass (cluster not supported), this is preventing those cards from
running on top of this module. This patch stops suricata on 'pfring_set_cluster' failure
only when error code != PF_RING_ERROR_NOT_SUPPORTED or cluster ID has not been explicitly
configured.

src/runmode-pfring.c
src/source-pfring.c
src/source-pfring.h

index fbbd8c91723457db2c41d829ac846a0ef385dd03..f08bdad80296857328deed8334408687ae778172 100644 (file)
@@ -109,6 +109,7 @@ void *OldParsePfringConfig(const char *iface)
     }
 
     strlcpy(pfconf->iface, iface, sizeof(pfconf->iface));
+    pfconf->flags = 0;
     pfconf->threads = 1;
     pfconf->cluster_id = 1;
 #ifdef HAVE_PFRING
@@ -143,6 +144,7 @@ void *OldParsePfringConfig(const char *iface)
         SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config");
     } else {
         pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
+        pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER;
         SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
     }
 
@@ -263,6 +265,7 @@ void *ParsePfringConfig(const char *iface)
     /* command line value has precedence */
     if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
         pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
+        pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER;
         SCLogDebug("Going to use command-line provided cluster-id %" PRId32,
                    pfconf->cluster_id);
     } else {
@@ -278,6 +281,7 @@ void *ParsePfringConfig(const char *iface)
                        "Could not get cluster-id from config");
         } else {
             pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
+            pfconf->flags |= PFRING_CONF_FLAGS_CLUSTER;
             SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
         }
     }
index 3e2ba6a8563c9dcd5106c38bdfcb7e3c6ec4832e..527086f564c730ea30443d3afbf2632295b12942 100644 (file)
@@ -485,8 +485,11 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data)
         if (rc != 0) {
             SCLogError(SC_ERR_PF_RING_SET_CLUSTER_FAILED, "pfring_set_cluster "
                     "returned %d for cluster-id: %d", rc, ptv->cluster_id);
-            pfconf->DerefFunc(pfconf);
-            return TM_ECODE_FAILED;
+            if (rc != PF_RING_ERROR_NOT_SUPPORTED || (pfconf->flags & PFRING_CONF_FLAGS_CLUSTER)) {
+                /* cluster is mandatory as explicitly specified in the configuration */
+                pfconf->DerefFunc(pfconf);
+                return TM_ECODE_FAILED;
+            }
         }
     }
 
index e0878454e12d6caa3c9942beb0f0d484edc730b1..9871f458f6ee0998c4734555d95ff840503d539a 100644 (file)
 #include <pfring.h>
 #endif
 
+typedef enum {
+    PFRING_CONF_FLAGS_CLUSTER = 0x1
+} PfringIfaceConfigFlags;
+
 typedef struct PfringIfaceConfig_
 {
+    uint32_t flags;
+
     /* cluster param */
     int cluster_id;
 #ifdef HAVE_PFRING