]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pfring: add support for 'default' interface
authorEric Leblond <eric@regit.org>
Mon, 21 Jan 2013 08:52:13 +0000 (09:52 +0100)
committerEric Leblond <eric@regit.org>
Mon, 21 Jan 2013 15:12:03 +0000 (16:12 +0100)
src/runmode-pfring.c
suricata.yaml.in

index d932864a8c880af763795cf7c31a3550a1d714f9..c1fa684502d86f575c08c2ba038f05365814275f 100644 (file)
@@ -194,6 +194,7 @@ void *ParsePfringConfig(const char *iface)
 {
     char *threadsstr = NULL;
     ConfNode *if_root;
+    ConfNode *if_default = NULL;
     ConfNode *pf_ring_node;
     PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf));
     char *tmpclusterid;
@@ -234,7 +235,10 @@ void *ParsePfringConfig(const char *iface)
     }
 
     if_root = ConfNodeLookupKeyValue(pf_ring_node, "interface", iface);
-    if (if_root == NULL) {
+
+    if_default = ConfNodeLookupKeyValue(pf_ring_node, "interface", "default");
+
+    if (if_root == NULL && if_default == NULL) {
         /* Switch to old mode */
         if_root = pf_ring_node;
         SCLogInfo("Unable to find pfring config for "
@@ -244,7 +248,13 @@ void *ParsePfringConfig(const char *iface)
         return pfconf;
     }
 
-    if (ConfGetChildValue(if_root, "threads", &threadsstr) != 1) {
+    /* If there is no setting for current interface use default one as main iface */
+    if (if_root == NULL) {
+        if_root = if_default;
+        if_default = NULL;
+    }
+
+    if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
         pfconf->threads = 1;
     } else {
         if (threadsstr != NULL) {
@@ -264,7 +274,7 @@ void *ParsePfringConfig(const char *iface)
         SCLogDebug("Going to use command-line provided cluster-id %" PRId32,
                    pfconf->cluster_id);
     } else {
-        if (ConfGetChildValue(if_root, "cluster-id", &tmpclusterid) != 1) {
+        if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) {
             SCLogError(SC_ERR_INVALID_ARGUMENT,
                        "Could not get cluster-id from config");
         } else {
@@ -282,7 +292,7 @@ void *ParsePfringConfig(const char *iface)
                        pfconf->bpf_filter);
         }
     } else {
-        if (ConfGetChildValue(if_root, "bpf-filter", &bpf_filter) == 1) {
+        if (ConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", &bpf_filter) == 1) {
             if (strlen(bpf_filter) > 0) {
                 pfconf->bpf_filter = SCStrdup(bpf_filter);
                 SCLogDebug("Going to use bpf filter %s", pfconf->bpf_filter);
@@ -296,7 +306,7 @@ void *ParsePfringConfig(const char *iface)
         SCLogDebug("Going to use command-line provided cluster-type");
         getctype = 1;
     } else {
-        if (ConfGetChildValue(if_root, "cluster-type", &tmpctype) != 1) {
+        if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) {
             SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,
                        "Could not get cluster-type fron config");
         } else {
@@ -324,7 +334,7 @@ void *ParsePfringConfig(const char *iface)
 
 #endif /* HAVE_PFRING_CLUSTER_TYPE */
 
-    if (ConfGetChildValue(if_root, "checksum-checks", &tmpctype) == 1) {
+    if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
         if (strcmp(tmpctype, "auto") == 0) {
             pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
         } else if (strcmp(tmpctype, "yes") == 0) {
index 05267654615c08753addeb039f18b045de565160..7caf4d35662496dcfc24b7c0ba75687d5494fc2d 100644 (file)
@@ -680,6 +680,9 @@ pfring:
   #  threads: 3
   #  cluster-id: 93
   #  cluster-type: cluster_flow
+  # Put default values here
+  - interface: default
+    #threads: 2
 
 pcap:
   - interface: eth0