[svn] commit: r2159 - in /trunk/src/lib/datasrc: ./ data_source.cc sqlite3_datasrc.cc tests/datasrc_unittest.cc tests/testdata/example.org tests/testdata/example.org.sqlite3
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jun 18 01:09:44 UTC 2010
Author: jinmei
Date: Fri Jun 18 01:09:44 2010
New Revision: 2159
Log:
use simpler version of Name::split() for better readability (trac #200)
Modified:
trunk/src/lib/datasrc/ (props changed)
trunk/src/lib/datasrc/data_source.cc
trunk/src/lib/datasrc/sqlite3_datasrc.cc
trunk/src/lib/datasrc/tests/datasrc_unittest.cc
trunk/src/lib/datasrc/tests/testdata/example.org
trunk/src/lib/datasrc/tests/testdata/example.org.sqlite3
Modified: trunk/src/lib/datasrc/data_source.cc
==============================================================================
--- trunk/src/lib/datasrc/data_source.cc (original)
+++ trunk/src/lib/datasrc/data_source.cc Fri Jun 18 01:09:44 2010
@@ -202,18 +202,18 @@
}
// Match downward, from the zone apex to the query name, looking for
-// referrals.
+// referrals. Note that we exclude the apex name and query name themselves;
+// they'll be handled in a normal lookup in the zone.
inline bool
hasDelegation(const DataSrc* ds, const Name* zonename, Query& q,
QueryTaskPtr task)
{
- const int nlen = task->qname.getLabelCount();
- const int diff = nlen - zonename->getLabelCount();
+ const int diff = task->qname.getLabelCount() - zonename->getLabelCount();
if (diff > 1) {
bool found = false;
RRsetList ref;
- for (int i = diff; i > 1; --i) {
- const Name sub(task->qname.split(i - 1, nlen - i));
+ for (int i = diff - 1; i > 0; --i) {
+ const Name sub(task->qname.split(i));
if (refQuery(sub, q.qclass(), ds, zonename, ref)) {
found = true;
break;
@@ -360,11 +360,11 @@
// Find the closest provable enclosing name for QNAME
Name enclosure(zonename);
- const int nlen = task->qname.getLabelCount();
- const int diff = nlen - enclosure.getLabelCount();
+ const int diff = task->qname.getLabelCount() -
+ enclosure.getLabelCount();
string hash2;
for (int i = 1; i <= diff; ++i) {
- enclosure = task->qname.split(i, nlen - i);
+ enclosure = task->qname.split(i);
string nodehash(nsec3->getHash(enclosure));
if (nodehash == hash1) {
break;
@@ -434,8 +434,7 @@
return (DataSrc::SUCCESS);
}
- const int nlen = task->qname.getLabelCount();
- const int diff = nlen - zonename->getLabelCount();
+ const int diff = task->qname.getLabelCount() - zonename->getLabelCount();
if (diff < 1) {
return (DataSrc::SUCCESS);
}
@@ -445,7 +444,7 @@
bool cname = false;
for (int i = 1; i <= diff; ++i) {
- const Name& wname(star.concatenate(task->qname.split(i, nlen - i)));
+ const Name& wname(star.concatenate(task->qname.split(i)));
QueryTask newtask(wname, task->qclass, task->qtype, Section::ANSWER(),
QueryTask::AUTH_QUERY);
result = doQueryTask(ds, zonename, newtask, wild);
@@ -541,8 +540,7 @@
// (Note that RRtype DS queries need to go to the parent.)
const int nlabels = task->qname.getLabelCount() - 1;
NameMatch match(nlabels != 0 && task->qtype == RRType::DS() ?
- task->qname.split(1, task->qname.getLabelCount() - 1) :
- task->qname);
+ task->qname.split(1) : task->qname);
findClosestEnclosure(match, task->qclass);
const DataSrc* datasource = match.bestDataSrc();
const Name* zonename = match.closestName();
Modified: trunk/src/lib/datasrc/sqlite3_datasrc.cc
==============================================================================
--- trunk/src/lib/datasrc/sqlite3_datasrc.cc (original)
+++ trunk/src/lib/datasrc/sqlite3_datasrc.cc Fri Jun 18 01:09:44 2010
@@ -330,7 +330,7 @@
Sqlite3DataSrc::findClosest(const Name& name, unsigned int* position) const {
const unsigned int nlabels = name.getLabelCount();
for (unsigned int i = 0; i < nlabels; ++i) {
- const Name matchname(name.split(i, nlabels - i));
+ const Name matchname(name.split(i));
const int rc = hasExactZone(matchname.toText().c_str());
if (rc >= 0) {
if (position != NULL) {
@@ -356,9 +356,7 @@
return;
}
- match.update(*this, match.qname().split(position,
- match.qname().getLabelCount() -
- position));
+ match.update(*this, match.qname().split(position));
}
DataSrc::Result
Modified: trunk/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- trunk/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ trunk/src/lib/datasrc/tests/datasrc_unittest.cc Fri Jun 18 01:09:44 2010
@@ -540,6 +540,15 @@
EXPECT_TRUE(it->isLast());
}
+TEST_F(DataSrcTest, DnameExact) {
+ // The example.org test zone has a DNAME RR for dname2.foo.example.org.
+ // A query for that name with a different RR type than DNAME shouldn't
+ // confuse delegation processing.
+ createAndProcessQuery(Name("dname2.foo.example.org"), RRClass::IN(),
+ RRType::A());
+ headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 1, 0);
+}
+
TEST_F(DataSrcTest, Cname) {
readAndProcessQuery("q_cname");
Modified: trunk/src/lib/datasrc/tests/testdata/example.org
==============================================================================
--- trunk/src/lib/datasrc/tests/testdata/example.org (original)
+++ trunk/src/lib/datasrc/tests/testdata/example.org Fri Jun 18 01:09:44 2010
@@ -11,3 +11,4 @@
sub.example.org. NS ns.sub.example.org.
ns.sub.example.org. A 192.0.2.101
dname.example.org. DNAME dname.example.info.
+dname2.foo.example.org. DNAME dname2.example.info.
Modified: trunk/src/lib/datasrc/tests/testdata/example.org.sqlite3
==============================================================================
Binary files - no diff available.
More information about the bind10-changes
mailing list