Properly initialize pfring runmode before using it. Fix malformed conf api calls.

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent 966119b6aa
commit 5d2f633c48

@ -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);

@ -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;

@ -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);

Loading…
Cancel
Save