From 5d2f633c48971d3bd9e83d9065b02ff15c109636 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 11 Apr 2011 22:01:57 +0200 Subject: [PATCH] Properly initialize pfring runmode before using it. Fix malformed conf api calls. --- src/runmode-pfring.c | 5 ++++- src/source-pfring.c | 12 ++++++------ src/suricata.c | 7 ++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index 4909d74480..ba94375166 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -44,7 +44,7 @@ static const char *default_mode_autofp = NULL; const char *RunModeIdsPfringGetDefaultMode(void) { #ifdef HAVE_PFRING - if (PfringConfGetThreads() == 1) { + if (PfringConfGetThreads() <= 1) { return default_mode_auto; } else { return default_mode_autofp; @@ -346,6 +346,9 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx) SCLogDebug("queues %s", queues); int pfring_threads = PfringConfGetThreads(); + if (pfring_threads == 0) { + pfring_threads = 1; + } /* create the threads */ for (thread = 0; thread < pfring_threads; thread++) { snprintf(tname, sizeof(tname), "RxPfring%"PRIu16, thread+1); diff --git a/src/source-pfring.c b/src/source-pfring.c index 61e31fd65e..a8824812c7 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -261,16 +261,16 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { return TM_ECODE_FAILED; memset(ptv, 0, sizeof(PfringThreadVars)); - if (ConfGet("runmode_pfring.cluster_id", &tmpclusterid) != 1) { - SCLogError(SC_ERR_PF_RING_GET_CLUSTERID_FAILED,"could not get runmode_pfring.cluster_id"); + if (ConfGet("pfring.cluster-id", &tmpclusterid) != 1) { + SCLogError(SC_ERR_PF_RING_GET_CLUSTERID_FAILED,"could not get pfring.cluster-id"); return TM_ECODE_FAILED; } else { ptv->cluster_id = (uint8_t)atoi(tmpclusterid); SCLogDebug("Going to use cluster-id %" PRId32, ptv->cluster_id); } - if (ConfGet("runmode_pfring.interface", &ptv->interface) != 1) { - SCLogError(SC_ERR_PF_RING_GET_INTERFACE_FAILED,"Could not get runmode_pfring.interface"); + if (ConfGet("pfring.interface", &ptv->interface) != 1) { + SCLogError(SC_ERR_PF_RING_GET_INTERFACE_FAILED,"Could not get pfring.interface"); return TM_ECODE_FAILED; } else { SCLogDebug("going to use interface %s",ptv->interface); @@ -288,8 +288,8 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { } #ifdef HAVE_PFRING_CLUSTER_TYPE - if (ConfGet("runmode_pfring.cluster_type", &tmpctype) != 1) { - SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get runmode_pfring.cluster_type"); + if (ConfGet("pfring.cluster-type", &tmpctype) != 1) { + SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get pfring.cluster-type"); return TM_ECODE_FAILED; } else if (strcmp(tmpctype, "cluster_round_robin") == 0 || strcmp(tmpctype, "cluster_flow") == 0) { ptv->ctype = (cluster_type)tmpctype; diff --git a/src/suricata.c b/src/suricata.c index a667a77c1b..d9c3da399d 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -485,9 +485,6 @@ int main(int argc, char **argv) { int opt; char pcap_dev[128]; -#ifdef HAVE_PFRING - char *pfring_dev = NULL; -#endif char *sig_file = NULL; char *conf_filename = NULL; char *pid_filename = NULL; @@ -1311,6 +1308,10 @@ int main(int argc, char **argv) fprintf(stderr, "ERROR: Failed to set runmode_pcap.single_pcap_dev\n"); exit(EXIT_FAILURE); } +#ifdef HAVE_PFRING + } else if (run_mode == RUNMODE_PFRING) { + PfringLoadConfig(); +#endif /* HAVE_PFRING */ } RunModeDispatch(run_mode, runmode_custom_mode, de_ctx);