From: Michal 'vorner' Vaner Date: Thu, 21 Jun 2012 13:31:24 +0000 (+0200) Subject: [1976] Modify the query to use ClientList X-Git-Tag: trac2351_base~97^2~7^2~2^2~21^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1af29fce7c3ed236d2db21289f8fcf76af15724c;p=thirdparty%2Fkea.git [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. --- diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index c4e69202d2..66b6503024 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -722,8 +723,8 @@ AuthSrvImpl::processNormalQuery(const IOMessage& io_message, Message& message, memory_client_class_ == question->getClass()) { const RRType& qtype = question->getType(); 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 { datasrc::Query query(message, cache_, dnssec_ok); data_sources_.doQuery(query); diff --git a/src/bin/auth/query.cc b/src/bin/auth/query.cc index f215c04ef8..af83f90449 100644 --- a/src/bin/auth/query.cc +++ b/src/bin/auth/query.cc @@ -19,6 +19,7 @@ #include #include +#include #include @@ -341,17 +342,17 @@ namespace { // 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; // 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) { - return (client.findZone(qname)); + return (list.find(qname)); } - return (client.findZone(qname.split(1))); + return (list.find(qname.split(1))); } } void -Query::process(datasrc::DataSourceClient& datasrc_client, +Query::process(datasrc::ClientList& client_list, const isc::dns::Name& qname, const isc::dns::RRType& qtype, isc::dns::Message& response, bool dnssec) { @@ -360,19 +361,18 @@ Query::process(datasrc::DataSourceClient& datasrc_client, QueryCleaner cleaner(*this); // 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 - 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 // REFUSED. In short, this is to be compatible with BIND 9, but the // background discussion is not that simple. See the relevant topic // at the BIND 10 developers's ML: // 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, // we may still have authority at the child side. If we do, the query // has to be handled there. @@ -384,7 +384,7 @@ Query::process(datasrc::DataSourceClient& datasrc_client, response_->setRcode(Rcode::REFUSED()); return; } - ZoneFinder& zfinder = *result.zone_finder; + ZoneFinder& zfinder = *result.finder_; // We have authority for a zone that contain the query name (possibly // 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, // add a proof that there's no closer name. if (dnssec_ && db_context->isWildcard()) { - addWildcardProof(*result.zone_finder, *db_context); + addWildcardProof(*result.finder_, *db_context); } break; case ZoneFinder::SUCCESS: @@ -475,17 +475,17 @@ Query::process(datasrc::DataSourceClient& datasrc_client, // section. // Checking the findZone() is a lightweight check to see if // qname is the zone origin. - if (result.code != result::SUCCESS || + if (result.exact_match_ || db_context->code != ZoneFinder::SUCCESS || (*qtype_ != RRType::NS() && !qtype_is_any)) { - addAuthAdditional(*result.zone_finder, additionals_); + addAuthAdditional(*result.finder_, additionals_); } // If the answer is a result of wildcard substitution, // add a proof that there's no closer name. if (dnssec_ && db_context->isWildcard()) { - addWildcardProof(*result.zone_finder, *db_context); + addWildcardProof(*result.finder_, *db_context); } break; case ZoneFinder::DELEGATION: @@ -505,12 +505,12 @@ Query::process(datasrc::DataSourceClient& datasrc_client, // If DNSSEC is requested, see whether there is a DS // record for this delegation. if (dnssec_) { - addDS(*result.zone_finder, db_context->rrset->getName()); + addDS(*result.finder_, db_context->rrset->getName()); } break; case ZoneFinder::NXDOMAIN: response_->setRcode(Rcode::NXDOMAIN()); - addSOA(*result.zone_finder); + addSOA(*result.finder_); if (dnssec_) { if (db_context->isNSECSigned() && db_context->rrset) { addNXDOMAINProofByNSEC(zfinder, db_context->rrset); @@ -520,7 +520,7 @@ Query::process(datasrc::DataSourceClient& datasrc_client, } break; case ZoneFinder::NXRRSET: - addSOA(*result.zone_finder); + addSOA(*result.finder_); if (dnssec_) { addNXRRsetProof(zfinder, *db_context); } @@ -538,11 +538,11 @@ Query::process(datasrc::DataSourceClient& datasrc_client, } void -Query::initialize(datasrc::DataSourceClient& datasrc_client, +Query::initialize(datasrc::ClientList& client_list, const isc::dns::Name& qname, const isc::dns::RRType& qtype, isc::dns::Message& response, bool dnssec) { - datasrc_client_ = &datasrc_client; + client_list_ = &client_list; qname_ = &qname; qtype_ = &qtype; response_ = &response; @@ -553,7 +553,7 @@ Query::initialize(datasrc::DataSourceClient& datasrc_client, void Query::reset() { - datasrc_client_ = NULL; + client_list_ = NULL; qname_ = NULL; qtype_ = NULL; response_ = NULL; @@ -565,10 +565,10 @@ Query::reset() { bool 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); } @@ -583,12 +583,12 @@ Query::processDSAtChild() { // by seeing the SOA. response_->setHeaderFlag(Message::HEADERFLAG_AA); response_->setRcode(Rcode::NOERROR()); - addSOA(*zresult.zone_finder); + addSOA(*zresult.finder_); 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 (dnssec_) { - addNXRRsetProof(*zresult.zone_finder, *ds_context); + addNXRRsetProof(*zresult.finder_, *ds_context); } } diff --git a/src/bin/auth/query.h b/src/bin/auth/query.h index dce19f7c89..1dc5ec01eb 100644 --- a/src/bin/auth/query.h +++ b/src/bin/auth/query.h @@ -32,7 +32,7 @@ class RRset; } namespace datasrc { -class DataSourceClient; +class ClientList; } namespace auth { @@ -55,8 +55,6 @@ namespace auth { /// separate attribute setter. /// - likewise, we'll eventually need to do per zone access control, for which /// we need querier's information such as its IP address. -/// - datasrc_client and response may better be parameters to process() instead -/// of the constructor. /// /// Note: The class name is intentionally the same as the one used in /// 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 /// 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 qtype The RR type of 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 /// possible. - void initialize(datasrc::DataSourceClient& datasrc_client, + void initialize(datasrc::ClientList& client_list, const isc::dns::Name& qname, const isc::dns::RRType& qtype, isc::dns::Message& response, bool dnssec = false); @@ -281,7 +279,7 @@ public: /// Query parameters will be set by the call to process() /// Query() : - datasrc_client_(NULL), qname_(NULL), qtype_(NULL), + client_list_(NULL), qname_(NULL), qtype_(NULL), dnssec_(false), dnssec_opt_(isc::datasrc::ZoneFinder::FIND_DEFAULT), response_(NULL) { @@ -318,14 +316,14 @@ public: /// shouldn't happen in real-life (as BadZone means wrong data, it should /// 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 qtype The RR type of 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 /// possible. - void process(datasrc::DataSourceClient& datasrc_client, + void process(datasrc::ClientList& client_list, const isc::dns::Name& qname, const isc::dns::RRType& qtype, isc::dns::Message& response, bool dnssec = false); @@ -483,7 +481,7 @@ public: }; private: - const isc::datasrc::DataSourceClient* datasrc_client_; + const isc::datasrc::ClientList* client_list_; const isc::dns::Name* qname_; const isc::dns::RRType* qtype_; bool dnssec_;