pfring: restore precedence of command line options.

remotes/origin/master-1.1.x
Eric Leblond 14 years ago
parent b2598f97e7
commit c3ba992652

@ -170,7 +170,9 @@ void *ParsePfringConfig(const char *iface)
char *tmpclusterid; char *tmpclusterid;
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
char *tmpctype = NULL; char *tmpctype = NULL;
/* TODO free me */
char * default_ctype = strdup("cluster_round_robin"); char * default_ctype = strdup("cluster_round_robin");
int getctype = 0;
#endif #endif
if (iface == NULL) { if (iface == NULL) {
@ -215,17 +217,37 @@ void *ParsePfringConfig(const char *iface)
if (pfconf->threads == 0) { if (pfconf->threads == 0) {
pfconf->threads = 1; pfconf->threads = 1;
} }
/* command line value has precedence */
if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
SCLogDebug("Going to use command-line provided cluster-id %" PRId32,
pfconf->cluster_id);
} else {
if (ConfGetChildValue(if_root, "cluster-id", &tmpclusterid) != 1) { if (ConfGetChildValue(if_root, "cluster-id", &tmpclusterid) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config"); SCLogError(SC_ERR_INVALID_ARGUMENT,
"Could not get cluster-id from config");
} else { } else {
pfconf->cluster_id = (uint16_t)atoi(tmpclusterid); pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id); SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
} }
}
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
if (ConfGet("pfring.cluster-type", &tmpctype) == 1) {
SCLogDebug("Going to use command-line provided cluster-type");
getctype = 1;
} else {
if (ConfGetChildValue(if_root, "cluster-type", &tmpctype) != 1) { if (ConfGetChildValue(if_root, "cluster-type", &tmpctype) != 1) {
SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get cluster-type fron config"); SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) { "Could not get cluster-type fron config");
} else {
getctype = 1;
}
}
if (getctype) {
if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)", SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)",
pfconf->iface); pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = (cluster_type)tmpctype;
@ -234,9 +256,13 @@ void *ParsePfringConfig(const char *iface)
pfconf->iface); pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = (cluster_type)tmpctype;
} else { } else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype); SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,
"invalid cluster-type %s",
tmpctype);
return NULL; return NULL;
} }
}
#endif #endif
return pfconf; return pfconf;

Loading…
Cancel
Save