pfring: Prefix messages with interface name

This commit modifies the log messages to follow the style of AF_PACKET
(and others). When the interface name is part of the message, the
message will be structured as: "<iface-name>: <message>"

Issue: 5975
pull/8787/head
Jeff Lucovsky 2 years ago committed by Victor Julien
parent 0ad6d4358f
commit 61783c4e42

@ -138,7 +138,7 @@ static void *OldParsePfringConfig(const char *iface)
(void) SC_ATOMIC_ADD(pfconf->ref, pfconf->threads); (void) SC_ATOMIC_ADD(pfconf->ref, pfconf->threads);
if (strncmp(pfconf->iface, "zc", 2) == 0) { if (strncmp(pfconf->iface, "zc", 2) == 0) {
SCLogInfo("ZC interface detected, not setting cluster-id"); SCLogInfo("%s: ZC interface detected, not setting cluster-id", pfconf->iface);
} }
else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) { else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster-id"); SCLogInfo("DNA interface detected, not setting cluster-id");
@ -156,20 +156,17 @@ static void *OldParsePfringConfig(const char *iface)
} }
if (strncmp(pfconf->iface, "zc", 2) == 0) { if (strncmp(pfconf->iface, "zc", 2) == 0) {
SCLogInfo("ZC interface detected, not setting cluster type for PF_RING (iface %s)", SCLogInfo("%s: ZC interface detected, not setting cluster type for PF_RING", pfconf->iface);
pfconf->iface);
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) { } else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster type for PF_RING (iface %s)", SCLogInfo(
pfconf->iface); "%s: DNA interface detected, not setting cluster type for PF_RING", pfconf->iface);
} else if (ConfGet("pfring.cluster-type", &tmpctype) != 1) { } else if (ConfGet("pfring.cluster-type", &tmpctype) != 1) {
SCLogError("Could not get cluster-type from config"); SCLogError("Could not get cluster-type from config");
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) { } else if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)", SCLogInfo("%s: Using round-robin cluster mode for PF_RING", pfconf->iface);
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = (cluster_type)tmpctype;
} else if (strcmp(tmpctype, "cluster_flow") == 0) { } else if (strcmp(tmpctype, "cluster_flow") == 0) {
SCLogInfo("Using flow cluster mode for PF_RING (iface %s)", SCLogInfo("%s: Using flow cluster mode for PF_RING", pfconf->iface);
pfconf->iface);
pfconf->ctype = (cluster_type)tmpctype; pfconf->ctype = (cluster_type)tmpctype;
} else { } else {
SCLogError("invalid cluster-type %s", tmpctype); SCLogError("invalid cluster-type %s", tmpctype);
@ -296,10 +293,10 @@ static void *ParsePfringConfig(const char *iface)
} else { } else {
if (strncmp(pfconf->iface, "zc", 2) == 0) { if (strncmp(pfconf->iface, "zc", 2) == 0) {
SCLogInfo("ZC interface detected, not setting cluster-id for PF_RING (iface %s)", SCLogInfo(
pfconf->iface); "%s: ZC interface detected, not setting cluster-id for PF_RING", pfconf->iface);
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) { } else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster-id for PF_RING (iface %s)", SCLogInfo("%s: DNA interface detected, not setting cluster-id for PF_RING",
pfconf->iface); pfconf->iface);
} else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) { } else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) {
SCLogError("Could not get cluster-id from config"); SCLogError("Could not get cluster-id from config");
@ -346,10 +343,10 @@ static void *ParsePfringConfig(const char *iface)
getctype = 1; getctype = 1;
} else { } else {
if (strncmp(pfconf->iface, "zc", 2) == 0) { if (strncmp(pfconf->iface, "zc", 2) == 0) {
SCLogInfo("ZC interface detected, not setting cluster type for PF_RING (iface %s)", SCLogInfo("%s: ZC interface detected, not setting cluster type for PF_RING",
pfconf->iface); pfconf->iface);
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) { } else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster type for PF_RING (iface %s)", SCLogInfo("%s: DNA interface detected, not setting cluster type for PF_RING",
pfconf->iface); pfconf->iface);
} else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) { } else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) {
SCLogError("Could not get cluster-type from config"); SCLogError("Could not get cluster-type from config");
@ -360,28 +357,24 @@ static void *ParsePfringConfig(const char *iface)
if (getctype) { if (getctype) {
if (strcmp(tmpctype, "cluster_round_robin") == 0) { if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("Using round-robin cluster mode for PF_RING (iface %s)." SCLogInfo("%s: Using round-robin cluster mode for PF_RING."
" This mode is not recommended.", " This mode is not recommended.",
pfconf->iface); pfconf->iface);
pfconf->ctype = CLUSTER_ROUND_ROBIN; pfconf->ctype = CLUSTER_ROUND_ROBIN;
} else if (strcmp(tmpctype, "cluster_flow") == 0) { } else if (strcmp(tmpctype, "cluster_flow") == 0) {
SCLogInfo("Using flow cluster mode for PF_RING (iface %s)", SCLogInfo("%s: Using flow cluster mode for PF_RING", pfconf->iface);
pfconf->iface);
pfconf->ctype = CLUSTER_FLOW; pfconf->ctype = CLUSTER_FLOW;
} else if (strcmp(tmpctype, "cluster_inner_flow") == 0) { } else if (strcmp(tmpctype, "cluster_inner_flow") == 0) {
SCLogInfo("Using flow cluster mode inner mode for PF_RING (iface %s)", pfconf->iface); SCLogInfo("%s: Using flow cluster mode inner mode for PF_RING", pfconf->iface);
pfconf->ctype = CLUSTER_INNER_FLOW; pfconf->ctype = CLUSTER_INNER_FLOW;
} else if (strcmp(tmpctype, "cluster_inner_flow_2_tuple") == 0) { } else if (strcmp(tmpctype, "cluster_inner_flow_2_tuple") == 0) {
SCLogInfo( SCLogInfo("%s: Using flow cluster inner 2 tuple mode for PF_RING", pfconf->iface);
"Using flow cluster inner 2 tuple mode for PF_RING (iface %s)", pfconf->iface);
pfconf->ctype = CLUSTER_INNER_FLOW_2_TUPLE; pfconf->ctype = CLUSTER_INNER_FLOW_2_TUPLE;
} else if (strcmp(tmpctype, "cluster_inner_flow_4_tuple") == 0) { } else if (strcmp(tmpctype, "cluster_inner_flow_4_tuple") == 0) {
SCLogInfo( SCLogInfo("%s: Using flow cluster inner 4 tuple mode for PF_RING", pfconf->iface);
"Using flow cluster inner 4 tuple mode for PF_RING (iface %s)", pfconf->iface);
pfconf->ctype = CLUSTER_INNER_FLOW_4_TUPLE; pfconf->ctype = CLUSTER_INNER_FLOW_4_TUPLE;
} else if (strcmp(tmpctype, "cluster_inner_flow_5_tuple") == 0) { } else if (strcmp(tmpctype, "cluster_inner_flow_5_tuple") == 0) {
SCLogInfo( SCLogInfo("%s: Using flow cluster inner 5 tuple mode for PF_RING", pfconf->iface);
"Using flow cluster inner 5 tuple mode for PF_RING (iface %s)", pfconf->iface);
pfconf->ctype = CLUSTER_INNER_FLOW_5_TUPLE; pfconf->ctype = CLUSTER_INNER_FLOW_5_TUPLE;
} else { } else {
SCLogError("invalid cluster-type %s", tmpctype); SCLogError("invalid cluster-type %s", tmpctype);
@ -399,14 +392,15 @@ static void *ParsePfringConfig(const char *iface)
} else if (strcmp(tmpctype, "rx-only") == 0) { } else if (strcmp(tmpctype, "rx-only") == 0) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_RXONLY; pfconf->checksum_mode = CHECKSUM_VALIDATION_RXONLY;
} else { } else {
SCLogError("Invalid value for checksum-checks for %s", pfconf->iface); SCLogError("%s: Invalid value for checksum-checks", pfconf->iface);
} }
} }
if (ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &bool_val) == 1) { if (ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &bool_val) == 1) {
if (bool_val) { if (bool_val) {
#ifdef HAVE_PF_RING_FLOW_OFFLOAD #ifdef HAVE_PF_RING_FLOW_OFFLOAD
SCLogConfig("Enabling bypass support in PF_RING for iface %s (if supported by underlying hw)", pfconf->iface); SCLogConfig("%s: Enabling bypass support in PF_RING (if supported by underlying hw)",
pfconf->iface);
pfconf->flags |= PFRING_CONF_FLAGS_BYPASS; pfconf->flags |= PFRING_CONF_FLAGS_BYPASS;
#else #else
SCLogError("Bypass is not supported by this Pfring version, please upgrade"); SCLogError("Bypass is not supported by this Pfring version, please upgrade");

Loading…
Cancel
Save