name.compare(getOrigin()).getRelation();
if (reln != NameComparisonResult::SUBDOMAIN &&
reln != NameComparisonResult::EQUAL) {
- isc_throw(OutOfZoneFind, name.toText() << " not in " <<
- getOrigin().toText());
+ isc_throw(OutOfZoneFind, name.toText() << " not in " << getOrigin());
}
// First, go through all superdomains from the origin down, searching for
if (result == DomainTree::EXACTMATCH) {
return (ResultType(ZoneFinder::SUCCESS, node, state.rrset_,
zonecut_flag));
- }
- if (result == DomainTree::PARTIALMATCH) {
+ } else if (result == DomainTree::PARTIALMATCH) {
assert(node != NULL);
if (state.dname_node_ != NULL) { // DNAME
LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_DNAME_FOUND).
FindNodeResult::FIND_WILDCARD |
zonecut_flag));
}
+ // Nothing really matched.
+ LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NOT_FOUND).arg(name);
+ return (ResultType(ZoneFinder::NXDOMAIN, node, state.rrset_));
+ } else {
+ // If the name is neither an exact or partial match, it is
+ // out of bailiwick, which is considered an error.
+ isc_throw(OutOfZoneFind, name.toText() << " not in " <<
+ origin_data_->getName());
}
- // Nothing really matched. The name may even be out-of-bailiwick.
- LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_NOT_FOUND).arg(name);
- return (ResultType(ZoneFinder::NXDOMAIN, node, state.rrset_));
}
} // unnamed namespace
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_FIND).arg(name).
arg(type);
- const NameComparisonResult::NameRelation reln =
- name.compare(origin_).getRelation();
- if (reln != NameComparisonResult::SUBDOMAIN &&
- reln != NameComparisonResult::EQUAL) {
- isc_throw(OutOfZoneFind, name.toText() <<
- " not in " << origin_.toText());
- }
-
// Get the node. All other cases than an exact match are handled
// in findNode(). We simply construct a result structure and return.
const ZoneData::FindNodeResult node_result =
const Name& name = getAdditionalName(rrset->getType(),
rdata_iterator->getCurrent());
+ // if the name is not in or below this zone, skip it
+ const NameComparisonResult::NameRelation reln =
+ name.compare(zone_data->origin_data_->getName()).getRelation();
+ if (reln != NameComparisonResult::SUBDOMAIN &&
+ reln != NameComparisonResult::EQUAL) {
+ continue;
+ }
const ZoneData::FindMutableNodeResult result =
zone_data->findNode<ZoneData::FindMutableNodeResult>(
name, ZoneFinder::FIND_GLUE_OK);
}
TYPED_TEST(DatabaseClientTest, findOutOfZone) {
- // If the query name is out-of-zone it should result in NXDOMAIN
+ // If the query name is out-of-zone it should result in an exception
boost::shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
vector<ConstRRsetPtr> target;
// Superdomain
- EXPECT_THROW(finder->find(Name("org"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("org"), this->qtype_), OutOfZoneFind);
EXPECT_THROW(finder->findAll(Name("org"), target), OutOfZoneFind);
// sharing a common ancestor
- EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("noexample.org"), this->qtype_),
+ OutOfZoneFind);
EXPECT_THROW(finder->findAll(Name("noexample.org"), target),
OutOfZoneFind);
// totally unrelated domain, smaller number of labels
- EXPECT_THROW(finder->find(Name("com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("com"), this->qtype_), OutOfZoneFind);
EXPECT_THROW(finder->findAll(Name("com"), target), OutOfZoneFind);
// totally unrelated domain, same number of labels
- EXPECT_THROW(finder->find(Name("example.com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("example.com"), this->qtype_),
+ OutOfZoneFind);
EXPECT_THROW(finder->findAll(Name("example.com"), target), OutOfZoneFind);
// totally unrelated domain, larger number of labels
- EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_,
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(finder->find(Name("more.example.com"), this->qtype_),
+ OutOfZoneFind);
EXPECT_THROW(finder->findAll(Name("more.example.com"), target),
OutOfZoneFind);
}
this->expected_rdatas_.clear();
this->expected_rdatas_.push_back("192.0.2.100");
{
- // Note: find() rejects out-of-zone query name with NXDOMAIN
+ // Note: find() rejects out-of-zone query name with an exception
// regardless of whether adding the RR succeeded, so this check
// actually doesn't confirm it.
SCOPED_TRACE("add out-of-zone RR");
EXPECT_THROW(this->updater_->getFinder().find(Name("example.com"),
- this->qtype_,
- ZoneFinder::FIND_DEFAULT),
+ this->qtype_),
OutOfZoneFind);
}
}
// These domains don't exist (and one is out of the zone)
findTest(Name("nothere.example.org"), RRType::A(), ZoneFinder::NXDOMAIN,
true, ConstRRsetPtr(), expected_flags);
- EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A(),
- ZoneFinder::FIND_DEFAULT), OutOfZoneFind);
+ EXPECT_THROW(zone_finder_.find(Name("example.net"), RRType::A()),
+ OutOfZoneFind);
}
TEST_F(InMemoryZoneFinderTest, find) {
// Note: basically we don't expect such a query to be performed (the common
// operation is to identify the best matching zone first then perform
// search it), but we shouldn't be confused even in the unexpected case.
- EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A(),
- ZoneFinder::FIND_DEFAULT),
+ EXPECT_THROW(zone_finder_.find(Name("org"), RRType::A()),
OutOfZoneFind);
}
EXPECT_EQ(RRClass::CH(), finder1.getClass());
EXPECT_EQ(RRClass::IN(), finder2.getClass());
// make sure the zone data is swapped, too
- EXPECT_THROW(finder1.find(origin_, RRType::NS(),
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ EXPECT_THROW(finder1.find(origin_, RRType::NS()), OutOfZoneFind);
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder1);
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), ZoneFinder::RESULT_DEFAULT, &finder2);
- EXPECT_THROW(finder2.find(other_origin, RRType::TXT(),
- ZoneFinder::FIND_DEFAULT),
- OutOfZoneFind);
+ EXPECT_THROW(finder2.find(other_origin, RRType::TXT()), OutOfZoneFind);
}
TEST_F(InMemoryZoneFinderTest, getFileName) {
self.assertRaises(isc.datasrc.OutOfZoneFind, finder.find,
isc.dns.Name("www.some.other.domain"),
- isc.dns.RRType.A(), finder.FIND_DEFAULT)
+ isc.dns.RRType.A())
result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
isc.dns.RRType.TXT(),