Browse Source

[trac744] Part of messages for data_source.cc

Michal 'vorner' Vaner 14 years ago
parent
commit
ea1f2d6e96
2 changed files with 60 additions and 1 deletions
  1. 26 1
      src/lib/datasrc/data_source.cc
  2. 34 0
      src/lib/datasrc/messagedef.mes

+ 26 - 1
src/lib/datasrc/data_source.cc

@@ -25,6 +25,7 @@
 #include <datasrc/cache.h>
 #include <datasrc/data_source.h>
 #include <datasrc/query.h>
+#include <datasrc/logger.h>
 
 #include <util/encode/base32hex.h>
 #include <util/hash/sha1.h>
@@ -83,7 +84,7 @@ class ZoneInfo {
 public:
     ZoneInfo(DataSrc* ts,
              const isc::dns::Name& n,
-             const isc::dns::RRClass& c, 
+             const isc::dns::RRClass& c,
              const isc::dns::RRType& t = isc::dns::RRType::ANY()) :
         top_source_(ts),
         dsm_(((t == RRType::DS() && n.getLabelCount() != 1)
@@ -123,6 +124,11 @@ getAdditional(Query& q, ConstRRsetPtr rrset) {
         const Rdata& rd(it->getCurrent());
         if (rrset->getType() == RRType::NS()) {
             const generic::NS& ns = dynamic_cast<const generic::NS&>(rd);
+            if (logger.isDebugEnabled(DBG_TRACE_DATA)) {
+                logger.debug(DBG_TRACE_DATA, DATASRC_QUERY_GET_NS_ADDITIONAL,
+                             ns.getNSName().toText().c_str(),
+                             rrset->getName().toText().c_str());
+            }
             q.tasks().push(QueryTaskPtr(
                                new QueryTask(q, ns.getNSName(),
                                              Message::SECTION_ADDITIONAL,
@@ -130,6 +136,11 @@ getAdditional(Query& q, ConstRRsetPtr rrset) {
                                              QueryTask::GETADDITIONAL)));
         } else if (rrset->getType() == RRType::MX()) {
             const generic::MX& mx = dynamic_cast<const generic::MX&>(rd);
+            if (logger.isDebugEnabled(DBG_TRACE_DATA)) {
+                logger.debug(DBG_TRACE_DATA, DATASRC_QUERY_GET_MX_ADDITIONAL,
+                             mx.getMXName().toText().c_str(),
+                             rrset->getName().toText().c_str());
+            }
             q.tasks().push(QueryTaskPtr(
                                new QueryTask(q, mx.getMXName(),
                                              Message::SECTION_ADDITIONAL,
@@ -143,11 +154,17 @@ getAdditional(Query& q, ConstRRsetPtr rrset) {
 // understand DNAME
 void
 synthesizeCname(QueryTaskPtr task, RRsetPtr rrset, RRsetList& target) {
+    if (logger.isDebugEnabled(DBG_TRACE_DATA)) {
+        logger.debug(DBG_TRACE_DATA, DATASRC_QUERY_SYNTH_CNAME,
+                     rrset->getName().toText().c_str());
+    }
     RdataIteratorPtr it = rrset->getRdataIterator();
 
     // More than one DNAME RR in the RRset is illegal, so we only have
     // to process the first one.
     if (it->isLast()) {
+        logger.error(DATASRC_QUERY_EMPTY_DNAME,
+                     rrset->getName().toText().c_str());
         return;
     }
 
@@ -171,16 +188,24 @@ synthesizeCname(QueryTaskPtr task, RRsetPtr rrset, RRsetList& target) {
 // to by a CNAME record
 void
 chaseCname(Query& q, QueryTaskPtr task, RRsetPtr rrset) {
+    if (logger.isDebugEnabled(DBG_TRACE_DATA)) {
+        logger.debug(DBG_TRACE_DATA, DATASRC_QUERY_FOLLOW_CNAME,
+                     rrset->getName().toText().c_str());
+    }
     RdataIteratorPtr it = rrset->getRdataIterator();
 
     // More than one CNAME RR in the RRset is illegal, so we only have
     // to process the first one.
     if (it->isLast()) {
+        logger.error(DATASRC_QUERY_EMPTY_CNAME,
+                     rrset->getName().toText().c_str());
         return;
     }
 
     // Stop chasing CNAMES after 16 lookups, to prevent loops
     if (q.tooMany()) {
+        logger.error(DATASRC_QUERY_TOO_MANY_CNAMES,
+                     rrset->getName().toText().c_str());
         return;
     }
 

+ 34 - 0
src/lib/datasrc/messagedef.mes

@@ -68,3 +68,37 @@ CACHE_ENABLE Enabling the cache
 CACHE_DISABLE Disabling the cache
 + The hotspot cache is disabled from now on. It is not going to store
 + information or return anything.
+
+QUERY_SYNTH_CNAME Synthesizing CNAME from DNAME on '%s'
++ Debug info. While answering a query, we met a DNAME. We'll return the DNAME,
++ but we're creating a CNAME for clients that don't understand DNAMEs.
+
+QUERY_EMPTY_DNAME The DNAME on '%s' is empty
++ We tried to synthesize a CNAME from this DNAME, but it contains no records.
++ This indicates problem with supplied data.
+
+QUERY_GET_NS_ADDITIONAL Addition of A/AAAA for '%s' requested by NS '%s'
++ Debug information. While processing a query, we met a NS record. It
++ references the mentioned address, so we want to look up A/AAAA records for it
++ and put it into the additional section.
+
+QUERY_GET_MX_ADDITIONAL Addition of A/AAAA for '%s' requested by MX '%s'
++ Debug information. While processing a query, we met a MX record. It
++ references the mentioned address, so we want to look up A/AAAA records for it
++ and put it into the additional section.
+
+QUERY_FOLLOW_CNAME Following CNAME at '%s'
++ Debug information. The domain is a CNAME (or a DNAME and we created a CNAME
++ for it already), so we're following it.
+
+QUERY_EMPTY_CNAME CNAME at '%s' is empty
++ We tried to follow a CNAME, but contains no records. We have nothing to
++ follow, so we will have nothing in the answer. This indicates a problem with
++ supplied data.
+
+QUERY_TOO_MANY_CNAMES CNAME chain limit exceeded at '%s'
++ While answering a query, we followed a CNAME. Then another one. And after 16
++ CNAMEs we decided it's enough and we won't follow more. Long CNAME chains
++ are discouraged, and this might be a loop as well. Note that some of the
++ CNAMEs might have been synthesised from DNAMEs internally. This indicates
++ a problem with supplied data.