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,28 +217,52 @@ void *ParsePfringConfig(const char *iface)
if (pfconf->threads == 0) { if (pfconf->threads == 0) {
pfconf->threads = 1; pfconf->threads = 1;
} }
if (ConfGetChildValue(if_root, "cluster-id", &tmpclusterid) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config"); /* command line value has precedence */
} else { if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
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 command-line provided cluster-id %" PRId32,
pfconf->cluster_id);
} else {
if (ConfGetChildValue(if_root, "cluster-id", &tmpclusterid) != 1) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Could not get cluster-id from config");
} else {
pfconf->cluster_id = (uint16_t)atoi(tmpclusterid);
SCLogDebug("Going to use cluster-id %" PRId32, pfconf->cluster_id);
}
} }
#ifdef HAVE_PFRING_CLUSTER_TYPE #ifdef HAVE_PFRING_CLUSTER_TYPE
if (ConfGetChildValue(if_root, "cluster-type", &tmpctype) != 1) { if (ConfGet("pfring.cluster-type", &tmpctype) == 1) {
SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get cluster-type fron config"); SCLogDebug("Going to use command-line provided cluster-type");
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) { getctype = 1;
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)",
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype;
} else if (strcmp(tmpctype, "cluster_flow") == 0) {
SCLogInfo("Using flow cluster mode for PF_RING (iface %s)",
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype;
} else { } else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,"invalid cluster-type %s",tmpctype); if (ConfGetChildValue(if_root, "cluster-type", &tmpctype) != 1) {
return NULL; SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,
"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)",
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype;
} else if (strcmp(tmpctype, "cluster_flow") == 0) {
SCLogInfo("Using flow cluster mode for PF_RING (iface %s)",
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype;
} else {
SCLogError(SC_ERR_INVALID_CLUSTER_TYPE,
"invalid cluster-type %s",
tmpctype);
return NULL;
}
}
#endif #endif
return pfconf; return pfconf;

Loading…
Cancel
Save