Browse Source

[1976] Modify the query to use ClientList

The call to it is worked around with the SingletonList. The tests are
not yet changed, so they don't compile.
Michal 'vorner' Vaner 13 years ago
parent
commit
1af29fce7c
3 changed files with 39 additions and 40 deletions
  1. 3 2
      src/bin/auth/auth_srv.cc
  2. 27 27
      src/bin/auth/query.cc
  3. 9 11
      src/bin/auth/query.h

+ 3 - 2
src/bin/auth/auth_srv.cc

@@ -55,6 +55,7 @@
 #include <auth/query.h>
 #include <auth/query.h>
 #include <auth/statistics.h>
 #include <auth/statistics.h>
 #include <auth/auth_log.h>
 #include <auth/auth_log.h>
+#include <auth/list.h>
 
 
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/lexical_cast.hpp>
@@ -722,8 +723,8 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, Message& message,
             memory_client_class_ == question->getClass()) {
             memory_client_class_ == question->getClass()) {
             const RRType& qtype = question->getType();
             const RRType& qtype = question->getType();
             const Name& qname = question->getName();
             const Name& qname = question->getName();
-            query_.process(memory_client_container_->getInstance(),
-                           qname, qtype, message, dnssec_ok);
+            SingletonList list(memory_client_container_->getInstance());
+            query_.process(list, qname, qtype, message, dnssec_ok);
         } else {
         } else {
             datasrc::Query query(message, cache_, dnssec_ok);
             datasrc::Query query(message, cache_, dnssec_ok);
             data_sources_.doQuery(query);
             data_sources_.doQuery(query);

+ 27 - 27
src/bin/auth/query.cc

@@ -19,6 +19,7 @@
 #include <dns/rdataclass.h>
 #include <dns/rdataclass.h>
 
 
 #include <datasrc/client.h>
 #include <datasrc/client.h>
+#include <datasrc/client_list.h>
 
 
 #include <auth/query.h>
 #include <auth/query.h>
 
 
@@ -341,17 +342,17 @@ namespace {
 // the qname consists of a single label, which also means it's the root name),
 // the qname consists of a single label, which also means it's the root name),
 // we should search the deepest zone we have (which should be the root zone;
 // we should search the deepest zone we have (which should be the root zone;
 // otherwise it's a query error).
 // otherwise it's a query error).
-DataSourceClient::FindResult
-findZone(const DataSourceClient& client, const Name& qname, RRType qtype) {
+ClientList::FindResult
+findZone(const ClientList& list, const Name& qname, RRType qtype) {
     if (qtype != RRType::DS() || qname.getLabelCount() == 1) {
     if (qtype != RRType::DS() || qname.getLabelCount() == 1) {
-        return (client.findZone(qname));
+        return (list.find(qname));
     }
     }
-    return (client.findZone(qname.split(1)));
+    return (list.find(qname.split(1)));
 }
 }
 }
 }
 
 
 void
 void
-Query::process(datasrc::DataSourceClient& datasrc_client,
+Query::process(datasrc::ClientList& client_list,
                const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                isc::dns::Message& response, bool dnssec)
                isc::dns::Message& response, bool dnssec)
 {
 {
@@ -360,19 +361,18 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
     QueryCleaner cleaner(*this);
     QueryCleaner cleaner(*this);
 
 
     // Set up query parameters for the rest of the (internal) methods
     // Set up query parameters for the rest of the (internal) methods
-    initialize(datasrc_client, qname, qtype, response, dnssec);
+    initialize(client_list, qname, qtype, response, dnssec);
 
 
     // Found a zone which is the nearest ancestor to QNAME
     // Found a zone which is the nearest ancestor to QNAME
-    const DataSourceClient::FindResult result = findZone(*datasrc_client_,
-                                                         *qname_, *qtype_);
+    const ClientList::FindResult result = findZone(*client_list_, *qname_,
+                                                   *qtype_);
 
 
     // If we have no matching authoritative zone for the query name, return
     // If we have no matching authoritative zone for the query name, return
     // REFUSED.  In short, this is to be compatible with BIND 9, but the
     // REFUSED.  In short, this is to be compatible with BIND 9, but the
     // background discussion is not that simple.  See the relevant topic
     // background discussion is not that simple.  See the relevant topic
     // at the BIND 10 developers's ML:
     // at the BIND 10 developers's ML:
     // https://lists.isc.org/mailman/htdig/bind10-dev/2010-December/001633.html
     // https://lists.isc.org/mailman/htdig/bind10-dev/2010-December/001633.html
-    if (result.code != result::SUCCESS &&
-        result.code != result::PARTIALMATCH) {
+    if (result.dsrc_client_ != NULL) {
         // If we tried to find a "parent zone" for a DS query and failed,
         // If we tried to find a "parent zone" for a DS query and failed,
         // we may still have authority at the child side.  If we do, the query
         // we may still have authority at the child side.  If we do, the query
         // has to be handled there.
         // has to be handled there.
@@ -384,7 +384,7 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
         response_->setRcode(Rcode::REFUSED());
         response_->setRcode(Rcode::REFUSED());
         return;
         return;
     }
     }
-    ZoneFinder& zfinder = *result.zone_finder;
+    ZoneFinder& zfinder = *result.finder_;
 
 
     // We have authority for a zone that contain the query name (possibly
     // We have authority for a zone that contain the query name (possibly
     // indirectly via delegation).  Look into the zone.
     // indirectly via delegation).  Look into the zone.
@@ -457,7 +457,7 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
             // If the answer is a result of wildcard substitution,
             // If the answer is a result of wildcard substitution,
             // add a proof that there's no closer name.
             // add a proof that there's no closer name.
             if (dnssec_ && db_context->isWildcard()) {
             if (dnssec_ && db_context->isWildcard()) {
-                addWildcardProof(*result.zone_finder, *db_context);
+                addWildcardProof(*result.finder_, *db_context);
             }
             }
             break;
             break;
         case ZoneFinder::SUCCESS:
         case ZoneFinder::SUCCESS:
@@ -475,17 +475,17 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
             // section.
             // section.
             // Checking the findZone() is a lightweight check to see if
             // Checking the findZone() is a lightweight check to see if
             // qname is the zone origin.
             // qname is the zone origin.
-            if (result.code != result::SUCCESS ||
+            if (result.exact_match_ ||
                 db_context->code != ZoneFinder::SUCCESS ||
                 db_context->code != ZoneFinder::SUCCESS ||
                 (*qtype_ != RRType::NS() && !qtype_is_any))
                 (*qtype_ != RRType::NS() && !qtype_is_any))
             {
             {
-                addAuthAdditional(*result.zone_finder, additionals_);
+                addAuthAdditional(*result.finder_, additionals_);
             }
             }
 
 
             // If the answer is a result of wildcard substitution,
             // If the answer is a result of wildcard substitution,
             // add a proof that there's no closer name.
             // add a proof that there's no closer name.
             if (dnssec_ && db_context->isWildcard()) {
             if (dnssec_ && db_context->isWildcard()) {
-                addWildcardProof(*result.zone_finder, *db_context);
+                addWildcardProof(*result.finder_, *db_context);
             }
             }
             break;
             break;
         case ZoneFinder::DELEGATION:
         case ZoneFinder::DELEGATION:
@@ -505,12 +505,12 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
             // If DNSSEC is requested, see whether there is a DS
             // If DNSSEC is requested, see whether there is a DS
             // record for this delegation.
             // record for this delegation.
             if (dnssec_) {
             if (dnssec_) {
-                addDS(*result.zone_finder, db_context->rrset->getName());
+                addDS(*result.finder_, db_context->rrset->getName());
             }
             }
             break;
             break;
         case ZoneFinder::NXDOMAIN:
         case ZoneFinder::NXDOMAIN:
             response_->setRcode(Rcode::NXDOMAIN());
             response_->setRcode(Rcode::NXDOMAIN());
-            addSOA(*result.zone_finder);
+            addSOA(*result.finder_);
             if (dnssec_) {
             if (dnssec_) {
                 if (db_context->isNSECSigned() && db_context->rrset) {
                 if (db_context->isNSECSigned() && db_context->rrset) {
                     addNXDOMAINProofByNSEC(zfinder, db_context->rrset);
                     addNXDOMAINProofByNSEC(zfinder, db_context->rrset);
@@ -520,7 +520,7 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
             }
             }
             break;
             break;
         case ZoneFinder::NXRRSET:
         case ZoneFinder::NXRRSET:
-            addSOA(*result.zone_finder);
+            addSOA(*result.finder_);
             if (dnssec_) {
             if (dnssec_) {
                 addNXRRsetProof(zfinder, *db_context);
                 addNXRRsetProof(zfinder, *db_context);
             }
             }
@@ -538,11 +538,11 @@ Query::process(datasrc::DataSourceClient& datasrc_client,
 }
 }
 
 
 void
 void
-Query::initialize(datasrc::DataSourceClient& datasrc_client,
+Query::initialize(datasrc::ClientList& client_list,
                   const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                   const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                   isc::dns::Message& response, bool dnssec)
                   isc::dns::Message& response, bool dnssec)
 {
 {
-    datasrc_client_ = &datasrc_client;
+    client_list_ = &client_list;
     qname_ = &qname;
     qname_ = &qname;
     qtype_ = &qtype;
     qtype_ = &qtype;
     response_ = &response;
     response_ = &response;
@@ -553,7 +553,7 @@ Query::initialize(datasrc::DataSourceClient& datasrc_client,
 
 
 void
 void
 Query::reset() {
 Query::reset() {
-    datasrc_client_ = NULL;
+    client_list_ = NULL;
     qname_ = NULL;
     qname_ = NULL;
     qtype_ = NULL;
     qtype_ = NULL;
     response_ = NULL;
     response_ = NULL;
@@ -565,10 +565,10 @@ Query::reset() {
 
 
 bool
 bool
 Query::processDSAtChild() {
 Query::processDSAtChild() {
-    const DataSourceClient::FindResult zresult =
-        datasrc_client_->findZone(*qname_);
+    const ClientList::FindResult zresult =
+        client_list_->find(*qname_, true);
 
 
-    if (zresult.code != result::SUCCESS) {
+    if (zresult.dsrc_client_) {
         return (false);
         return (false);
     }
     }
 
 
@@ -583,12 +583,12 @@ Query::processDSAtChild() {
     // by seeing the SOA.
     // by seeing the SOA.
     response_->setHeaderFlag(Message::HEADERFLAG_AA);
     response_->setHeaderFlag(Message::HEADERFLAG_AA);
     response_->setRcode(Rcode::NOERROR());
     response_->setRcode(Rcode::NOERROR());
-    addSOA(*zresult.zone_finder);
+    addSOA(*zresult.finder_);
     ConstZoneFinderContextPtr ds_context =
     ConstZoneFinderContextPtr ds_context =
-        zresult.zone_finder->find(*qname_, RRType::DS(), dnssec_opt_);
+        zresult.finder_->find(*qname_, RRType::DS(), dnssec_opt_);
     if (ds_context->code == ZoneFinder::NXRRSET) {
     if (ds_context->code == ZoneFinder::NXRRSET) {
         if (dnssec_) {
         if (dnssec_) {
-            addNXRRsetProof(*zresult.zone_finder, *ds_context);
+            addNXRRsetProof(*zresult.finder_, *ds_context);
         }
         }
     }
     }
 
 

+ 9 - 11
src/bin/auth/query.h

@@ -32,7 +32,7 @@ class RRset;
 }
 }
 
 
 namespace datasrc {
 namespace datasrc {
-class DataSourceClient;
+class ClientList;
 }
 }
 
 
 namespace auth {
 namespace auth {
@@ -55,8 +55,6 @@ namespace auth {
 ///   separate attribute setter.
 ///   separate attribute setter.
 /// - likewise, we'll eventually need to do per zone access control, for which
 /// - likewise, we'll eventually need to do per zone access control, for which
 ///   we need querier's information such as its IP address.
 ///   we need querier's information such as its IP address.
-/// - datasrc_client and response may better be parameters to process() instead
-///   of the constructor.
 ///
 ///
 /// <b>Note:</b> The class name is intentionally the same as the one used in
 /// <b>Note:</b> The class name is intentionally the same as the one used in
 /// the datasrc library.  This is because the plan is to eventually merge
 /// the datasrc library.  This is because the plan is to eventually merge
@@ -240,14 +238,14 @@ private:
     /// This is the first step of the process() method, and initializes
     /// This is the first step of the process() method, and initializes
     /// the member data
     /// the member data
     ///
     ///
-    /// \param datasrc_client The datasource wherein the answer to the query is
-    /// to be found.
+    /// \param client_list The datasource list wherein the answer to the query
+    /// is to be found.
     /// \param qname The query name
     /// \param qname The query name
     /// \param qtype The RR type of the query
     /// \param qtype The RR type of the query
     /// \param response The response message to store the answer to the query.
     /// \param response The response message to store the answer to the query.
     /// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
     /// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
     ///     possible.
     ///     possible.
-    void initialize(datasrc::DataSourceClient& datasrc_client,
+    void initialize(datasrc::ClientList& client_list,
                     const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                     const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                     isc::dns::Message& response, bool dnssec = false);
                     isc::dns::Message& response, bool dnssec = false);
 
 
@@ -281,7 +279,7 @@ public:
     /// Query parameters will be set by the call to process()
     /// Query parameters will be set by the call to process()
     ///
     ///
     Query() :
     Query() :
-        datasrc_client_(NULL), qname_(NULL), qtype_(NULL),
+        client_list_(NULL), qname_(NULL), qtype_(NULL),
         dnssec_(false), dnssec_opt_(isc::datasrc::ZoneFinder::FIND_DEFAULT),
         dnssec_(false), dnssec_opt_(isc::datasrc::ZoneFinder::FIND_DEFAULT),
         response_(NULL)
         response_(NULL)
     {
     {
@@ -318,14 +316,14 @@ public:
     /// shouldn't happen in real-life (as BadZone means wrong data, it should
     /// shouldn't happen in real-life (as BadZone means wrong data, it should
     /// have been rejected upon loading).
     /// have been rejected upon loading).
     ///
     ///
-    /// \param datasrc_client The datasource wherein the answer to the query is
-    /// to be found.
+    /// \param client_list The datasource list wherein the answer to the query
+    /// is to be found.
     /// \param qname The query name
     /// \param qname The query name
     /// \param qtype The RR type of the query
     /// \param qtype The RR type of the query
     /// \param response The response message to store the answer to the query.
     /// \param response The response message to store the answer to the query.
     /// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
     /// \param dnssec If the answer should include signatures and NSEC/NSEC3 if
     ///     possible.
     ///     possible.
-    void process(datasrc::DataSourceClient& datasrc_client,
+    void process(datasrc::ClientList& client_list,
                  const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                  const isc::dns::Name& qname, const isc::dns::RRType& qtype,
                  isc::dns::Message& response, bool dnssec = false);
                  isc::dns::Message& response, bool dnssec = false);
 
 
@@ -483,7 +481,7 @@ public:
     };
     };
 
 
 private:
 private:
-    const isc::datasrc::DataSourceClient* datasrc_client_;
+    const isc::datasrc::ClientList* client_list_;
     const isc::dns::Name* qname_;
     const isc::dns::Name* qname_;
     const isc::dns::RRType* qtype_;
     const isc::dns::RRType* qtype_;
     bool dnssec_;
     bool dnssec_;