From: Remi Gacogne Date: Mon, 16 Nov 2020 11:09:20 +0000 (+0100) Subject: dnsdist: Add the response code in the packet cache dump X-Git-Tag: auth-4.4.0-beta1~10^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9737%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Add the response code in the packet cache dump --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index d85f1d7050..2dad7ca4ba 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1523,6 +1523,7 @@ fuzz_target_proxyprotocol_LDFLAGS = $(fuzz_targets_ldflags) fuzz_target_proxyprotocol_LDADD = $(fuzz_targets_libs) fuzz_target_dnsdistcache_SOURCES = \ + dns.cc dns.hh \ dnsdist-cache.cc dnsdist-cache.hh \ dnsdist-ecs.cc dnsdist-ecs.hh \ dnslabeltext.cc \ diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc index 79f12234f2..ddf00bfa94 100644 --- a/pdns/dnsdist-cache.cc +++ b/pdns/dnsdist-cache.cc @@ -474,7 +474,14 @@ uint64_t DNSDistPacketCache::dump(int fd) count++; try { - fprintf(fp.get(), "%s %" PRId64 " %s ; key %" PRIu32 ", length %" PRIu16 ", tcp %d, added %" PRId64 "\n", value.qname.toString().c_str(), static_cast(value.validity - now), QType(value.qtype).getName().c_str(), entry.first, value.len, value.tcp, static_cast(value.added)); + uint8_t rcode = 0; + if (value.len >= sizeof(dnsheader)) { + dnsheader dh; + memcpy(&dh, value.value.data(), sizeof(dnsheader)); + rcode = dh.rcode; + } + + fprintf(fp.get(), "%s %" PRId64 " %s ; rcode %" PRIu8 ", key %" PRIu32 ", length %" PRIu16 ", tcp %d, added %" PRId64 "\n", value.qname.toString().c_str(), static_cast(value.validity - now), QType(value.qtype).getName().c_str(), rcode, entry.first, value.len, value.tcp, static_cast(value.added)); } catch(...) { fprintf(fp.get(), "; error printing '%s'\n", value.qname.empty() ? "EMPTY" : value.qname.toString().c_str()); diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index 1bea3b3330..a5f6c811e8 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -210,7 +210,7 @@ testrunner_SOURCES = \ bpf-filter.cc bpf-filter.hh \ cachecleaner.hh \ circular_buffer.hh \ - dns.hh \ + dns.cc dns.hh \ dnscrypt.cc dnscrypt.hh \ dnsdist-backend.cc \ dnsdist-cache.cc dnsdist-cache.hh \