From 6eada54fc8b78c09050295f5c99d5edc08fe392f Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 16 Oct 2019 09:03:14 -0600 Subject: [PATCH] eve/dns: don't log warning if dns log version not set If the DNS log version is not set, we default to v2. This should not be warning, but better logged at the config level. A warning will still be logged if the value is set but is not 1 or 2. --- src/output-json-dns.c | 46 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 676866b750..4045c97da3 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -510,28 +510,36 @@ static DnsVersion JsonDnsParseVersion(ConfNode *conf) DnsVersion version = DNS_VERSION_DEFAULT; intmax_t config_version; - if (ConfGetChildValueInt(conf, "version", &config_version)) { - switch(config_version) { - case 1: - version = DNS_VERSION_1; - break; - case 2: - version = DNS_VERSION_2; - break; - default: - SCLogWarning(SC_ERR_INVALID_ARGUMENT, - "invalid eve-log dns version option: %"PRIuMAX", " - "forcing it to version %u", - config_version, DNS_VERSION_DEFAULT); - version = DNS_VERSION_DEFAULT; - break; + const ConfNode *has_version = ConfNodeLookupChild(conf, "version"); + + if (has_version != NULL) { + bool invalid = false; + if (ConfGetChildValueInt(conf, "version", &config_version)) { + switch(config_version) { + case 1: + version = DNS_VERSION_1; + break; + case 2: + version = DNS_VERSION_2; + break; + default: + invalid = true; + break; + } + } else { + invalid = true; + } + if (invalid) { + SCLogWarning(SC_ERR_INVALID_ARGUMENT, + "invalid eve-log dns version option: %s, " + "defaulting to version %u", + has_version->val, version); } } else { - SCLogWarning(SC_ERR_INVALID_ARGUMENT, - "eve-log dns version not found, forcing it to version %u", - DNS_VERSION_DEFAULT); - version = DNS_VERSION_DEFAULT; + SCLogConfig("eve-log dns version not set, defaulting to version %u", + version); } + return version; }