BIND 10 master, updated. 19197b5bc9f2955bd6a8ca48a2d04472ed696e81 [master] 1. Add changelog. 2. Add cache test data file EXTRA_DISTOF
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Mar 7 05:56:29 UTC 2011
The branch, master has been updated
via 19197b5bc9f2955bd6a8ca48a2d04472ed696e81 (commit)
via fa64874fe02ff6ab8a782e0ede0d70ff2c95783e (commit)
via 996e2593c867478eec8f2b3700aa52776528394b (commit)
via 86355ec5ded2f1988dc466f8844360c78e8454a7 (commit)
via d3b169adf97f9c5a4990400e54562d644016fdaf (commit)
via 7de2a6f3f96d466ed24f7d8b24708a30ee679729 (commit)
via 2e46317ec615067947983aa9ebcce371a6a8fd2f (commit)
from 44bf7654cb3ce85fe63fa47c7b39f48bb041d4de (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 19197b5bc9f2955bd6a8ca48a2d04472ed696e81
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Mon Mar 7 13:56:16 2011 +0800
[master] 1. Add changelog. 2. Add cache test data file EXTRA_DISTOF
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 ++
src/lib/cache/message_entry.cc | 99 +++++++++++++++---------
src/lib/cache/tests/Makefile.am | 2 +
src/lib/cache/tests/message_entry_unittest.cc | 67 +++++++++++++---
src/lib/cache/tests/testdata/message_fromWire7 | 27 +++++++
src/lib/cache/tests/testdata/message_fromWire8 | 23 ++++++
6 files changed, 176 insertions(+), 48 deletions(-)
create mode 100644 src/lib/cache/tests/testdata/message_fromWire7
create mode 100644 src/lib/cache/tests/testdata/message_fromWire8
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 7d140ec..690595a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+ 188. [bug] zhang likun
+ Make the rrset trust level ranking algorithm used by
+ isc::cache::MessageEntry::getRRsetTrustLevel() follow RFC2181
+ section 5.4.1.
+ (Trac #595 git)
+
187. [bug] zhang likun
Fix the assert error in class isc::cache::RRsetCache by adding the
check for empty pointer and test case for it.
diff --git a/src/lib/cache/message_entry.cc b/src/lib/cache/message_entry.cc
index f23b9d5..6396167 100644
--- a/src/lib/cache/message_entry.cc
+++ b/src/lib/cache/message_entry.cc
@@ -23,6 +23,34 @@
using namespace isc::dns;
using namespace std;
+// Put file scope functions in unnamed namespace.
+namespace {
+
+// Get the shortest existing ancestor which is the owner name of
+// one DNAME record for the given query name.
+// Note: there may be multiple DNAME records(DNAME chain) in answer
+// section. In most cases they are in order, but the code can't depend
+// on that, it has to find the starter by iterating the DNAME chain.
+Name
+getDNAMEChainStarter(const Message& message, const Name& query_name) {
+ Name dname = query_name;
+ RRsetIterator rrset_iter = message.beginSection(Message::SECTION_ANSWER);
+ while(rrset_iter != message.endSection(Message::SECTION_ANSWER)) {
+ if ((*rrset_iter)->getType() == RRType::DNAME()) {
+ const Name& rrname = (*rrset_iter)->getName();
+ if (NameComparisonResult::SUBDOMAIN ==
+ dname.compare(rrname).getRelation()) {
+ dname = rrname;
+ }
+ }
+ ++rrset_iter;
+ }
+
+ return (dname);
+}
+
+} // End of unnamed namespace
+
namespace isc {
namespace cache {
@@ -120,48 +148,45 @@ MessageEntry::getRRsetTrustLevel(const Message& message,
switch(section) {
case Message::SECTION_ANSWER: {
if (aa) {
- RRsetIterator rrset_iter = message.beginSection(section);
-
- // Make sure we are inspecting the right RRset
- while((*rrset_iter)->getName() != rrset->getName() &&
- (*rrset_iter)->getType() != rrset->getType() &&
- rrset_iter != message.endSection(section)) {
- ++rrset_iter;
- }
- assert(rrset_iter != message.endSection(section));
-
// According RFC2181 section 5.4.1, only the record
// describing that ailas is necessarily authoritative.
- // If there is one or more CNAME records in answer section.
- // CNAME records is assumed as the first rrset.
- if ((*rrset_iter)->getType() == RRType::CNAME()) {
- // TODO: real equals for RRsets?
- if ((*rrset_iter).get() == rrset.get()) {
- return (RRSET_TRUST_ANSWER_AA);
- } else {
- return (RRSET_TRUST_ANSWER_NONAA);
+ // If there are CNAME(Not synchronized from DNAME)
+ // records in answer section, only the CNAME record
+ // whose owner name is same with qname is assumed as
+ // authoritative, all the left records are not authoritative.
+ //
+ // If there are DNAME records in answer section,
+ // Only the start DNAME and the synchronized CNAME record
+ // from it are authoritative, any other records in answer
+ // section are non-authoritative.
+ QuestionIterator quest_iter = message.beginQuestion();
+ // Make sure question section is not empty.
+ assert( quest_iter != message.endQuestion());
+
+ const Name& query_name = (*quest_iter)->getName();
+ const RRType& type = rrset->getType();
+ const Name& name = rrset->getName();
+ if ((type == RRType::CNAME() && name == query_name) ||
+ (type == RRType::DNAME() &&
+ name == getDNAMEChainStarter(message, query_name))) {
+ return (RRSET_TRUST_ANSWER_AA);
+ } else {
+ // If there is a CNAME record whose ower name is the same as
+ // the query name in answer section, the other records in answer
+ // section are non-authoritative, except the starter of DNAME
+ // chain (only checking CNAME is enough, because if the CNAME
+ // record is synthesized from a DNAME record, that DNAME
+ // record must be the starter of the DNAME chain).
+ RRsetIterator iter = message.beginSection(Message::SECTION_ANSWER);
+ while(iter != message.endSection(Message::SECTION_ANSWER)) {
+ if ((*iter)->getType() == RRType::CNAME() &&
+ (*iter)->getName() == query_name) {
+ return (RRSET_TRUST_ANSWER_NONAA);
+ }
+ ++iter;
}
}
-
- // Here, if the first rrset is DNAME, then assume the
- // second rrset is synchronized CNAME record, except
- // these two records, any other records in answer section
- // should be treated as non-authoritative.
- // TODO, this part logic should be revisited later,
- // since it's not mentioned by RFC2181.
- if ((*rrset_iter)->getType() == RRType::DNAME()) {
- // TODO: real equals for RRsets?
- if ((*rrset_iter).get() == rrset.get() ||
- ((++rrset_iter) != message.endSection(section) &&
- (*rrset_iter).get() == rrset.get())) {
- return (RRSET_TRUST_ANSWER_AA);
- } else {
- return (RRSET_TRUST_ANSWER_NONAA);
- }
- }
-
return (RRSET_TRUST_ANSWER_AA);
-
} else {
return (RRSET_TRUST_ANSWER_NONAA);
}
diff --git a/src/lib/cache/tests/Makefile.am b/src/lib/cache/tests/Makefile.am
index b93c9a7..6f05f74 100644
--- a/src/lib/cache/tests/Makefile.am
+++ b/src/lib/cache/tests/Makefile.am
@@ -64,3 +64,5 @@ EXTRA_DIST += testdata/message_fromWire3
EXTRA_DIST += testdata/message_fromWire4
EXTRA_DIST += testdata/message_fromWire5
EXTRA_DIST += testdata/message_fromWire6
+EXTRA_DIST += testdata/message_fromWire7
+EXTRA_DIST += testdata/message_fromWire8
diff --git a/src/lib/cache/tests/message_entry_unittest.cc b/src/lib/cache/tests/message_entry_unittest.cc
index 3b2711a..a96c441 100644
--- a/src/lib/cache/tests/message_entry_unittest.cc
+++ b/src/lib/cache/tests/message_entry_unittest.cc
@@ -29,7 +29,7 @@ using namespace isc;
using namespace isc::dns;
using namespace std;
-static uint32_t MAX_UINT32 = numeric_limits<uint32_t>::max();
+static uint32_t MAX_UINT32 = numeric_limits<uint32_t>::max();
namespace {
@@ -74,7 +74,6 @@ public:
message_parse(Message::PARSE),
message_render(Message::RENDER)
{
-
rrset_cache_.reset(new RRsetCache(RRSET_CACHE_DEFAULT_SIZE, class_));
}
@@ -108,7 +107,6 @@ TEST_F(MessageEntryTest, testParseRRset) {
TEST_F(MessageEntryTest, testGetRRsetTrustLevel_AA) {
messageFromFile(message_parse, "message_fromWire3");
DerivedMessageEntry message_entry(message_parse, rrset_cache_);
-
RRsetIterator rrset_iter = message_parse.beginSection(Message::SECTION_ANSWER);
RRsetTrustLevel level = message_entry.getRRsetTrustLevelForTest(message_parse,
@@ -164,7 +162,54 @@ TEST_F(MessageEntryTest, testGetRRsetTrustLevel_CNAME) {
level = message_entry.getRRsetTrustLevelForTest(message_parse,
*rrset_iter,
Message::SECTION_ANSWER);
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_NONAA);
+}
+
+TEST_F(MessageEntryTest, testGetRRsetTrustLevel_CNAME_and_DNAME) {
+ messageFromFile(message_parse, "message_fromWire7");
+ DerivedMessageEntry message_entry(message_parse, rrset_cache_);
+ RRsetIterator rrset_iter = message_parse.beginSection(Message::SECTION_ANSWER);
+ RRsetTrustLevel level = message_entry.getRRsetTrustLevelForTest(message_parse,
+ *rrset_iter,
+ Message::SECTION_ANSWER);
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_AA);
+ // All the left rrset are non-authoritative
+ ++rrset_iter;
+ while (rrset_iter != message_parse.endSection(Message::SECTION_ANSWER)) {
+ level = message_entry.getRRsetTrustLevelForTest(message_parse,
+ *rrset_iter,
+ Message::SECTION_ANSWER);
+ ++rrset_iter;
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_NONAA);
+ }
+}
+
+TEST_F(MessageEntryTest, testGetRRsetTrustLevel_DNAME_and_CNAME) {
+ messageFromFile(message_parse, "message_fromWire8");
+ DerivedMessageEntry message_entry(message_parse, rrset_cache_);
+ RRsetIterator rrset_iter = message_parse.beginSection(Message::SECTION_ANSWER);
+ RRsetTrustLevel level = message_entry.getRRsetTrustLevelForTest(message_parse,
+ *rrset_iter,
+ Message::SECTION_ANSWER);
+ // Test the deepest DNAME
EXPECT_EQ(level, RRSET_TRUST_ANSWER_AA);
+ ++rrset_iter;
+ // Test the synchronized CNAME
+ level = message_entry.getRRsetTrustLevelForTest(message_parse,
+ *rrset_iter,
+ Message::SECTION_ANSWER);
+ ++rrset_iter;
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_AA);
+
+ ++rrset_iter;
+ // All the left rrset are non-authoritative
+ while (rrset_iter != message_parse.endSection(Message::SECTION_ANSWER)) {
+ level = message_entry.getRRsetTrustLevelForTest(message_parse,
+ *rrset_iter,
+ Message::SECTION_ANSWER);
+ ++rrset_iter;
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_NONAA);
+ }
}
TEST_F(MessageEntryTest, testGetRRsetTrustLevel_DNAME) {
@@ -186,7 +231,7 @@ TEST_F(MessageEntryTest, testGetRRsetTrustLevel_DNAME) {
level = message_entry.getRRsetTrustLevelForTest(message_parse,
*rrset_iter,
Message::SECTION_ANSWER);
- EXPECT_EQ(level, RRSET_TRUST_ANSWER_AA);
+ EXPECT_EQ(level, RRSET_TRUST_ANSWER_NONAA);
}
// We only test the expire_time of the message entry.
@@ -204,8 +249,8 @@ TEST_F(MessageEntryTest, testGetRRsetEntries) {
messageFromFile(message_parse, "message_fromWire3");
DerivedMessageEntry message_entry(message_parse, rrset_cache_);
vector<RRsetEntryPtr> vec;
-
- // the time is bigger than the smallest expire time of
+
+ // the time is bigger than the smallest expire time of
// the rrset in message.
time_t expire_time = time(NULL) + 10802;
EXPECT_FALSE(message_entry.getRRsetEntriesForTest(vec, expire_time));
@@ -215,17 +260,17 @@ TEST_F(MessageEntryTest, testGenMessage) {
messageFromFile(message_parse, "message_fromWire3");
DerivedMessageEntry message_entry(message_parse, rrset_cache_);
time_t expire_time = message_entry.getExpireTime();
-
+
Message msg(Message::RENDER);
EXPECT_FALSE(message_entry.genMessage(expire_time + 2, msg));
message_entry.genMessage(time(NULL), msg);
// Check whether the generated message is same with cached one.
-
+
EXPECT_TRUE(msg.getHeaderFlag(Message::HEADERFLAG_AA));
EXPECT_FALSE(msg.getHeaderFlag(Message::HEADERFLAG_TC));
- EXPECT_EQ(1, sectionRRsetCount(msg, Message::SECTION_ANSWER));
- EXPECT_EQ(1, sectionRRsetCount(msg, Message::SECTION_AUTHORITY));
- EXPECT_EQ(5, sectionRRsetCount(msg, Message::SECTION_ADDITIONAL));
+ EXPECT_EQ(1, sectionRRsetCount(msg, Message::SECTION_ANSWER));
+ EXPECT_EQ(1, sectionRRsetCount(msg, Message::SECTION_AUTHORITY));
+ EXPECT_EQ(5, sectionRRsetCount(msg, Message::SECTION_ADDITIONAL));
// Check the rrset in answer section.
EXPECT_EQ(1, msg.getRRCount(Message::SECTION_ANSWER));
diff --git a/src/lib/cache/tests/testdata/message_fromWire7 b/src/lib/cache/tests/testdata/message_fromWire7
new file mode 100644
index 0000000..7b10b5d
--- /dev/null
+++ b/src/lib/cache/tests/testdata/message_fromWire7
@@ -0,0 +1,27 @@
+#
+# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1155
+# ;; flags: qr aa rd; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0
+# ;; WARNING: recursion requested but not available
+#
+# ;; QUESTION SECTION:
+# ;test.example.com. IN A
+#
+# ;; ANSWER SECTION:
+# test.example.com. 21600 IN CNAME cname.a.dname.example.com.
+# dname.example.com. 21600 IN DNAME dname.example.org.
+# cname.a.dname.example.com. 21600 IN CNAME cname.a.dname.example.org.
+# dname.example.org. 21600 IN DNAME dname.example.org.
+# cname.a.dname.example.org. 21600 IN CNAME cname.a.dname.example.org.
+
+0424 8500
+ 00 01 00 05 00 00 00 00 04 74 65 73
+ 74 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 00 01
+ 00 01 c0 0c 00 05 00 01 00 00 54 60 00 10 05 63
+ 6e 61 6d 65 01 61 05 64 6e 61 6d 65 c0 11 c0 36
+ 00 27 00 01 00 00 54 60 00 13 05 64 6e 61 6d 65
+ 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 c0 2e 00
+ 05 00 01 00 00 54 60 00 0a 05 63 6e 61 6d 65 01
+ 61 c0 4a c0 4a 00 27 00 01 00 00 54 60 00 13 05
+ 64 6e 61 6d 65 07 65 78 61 6d 70 6c 65 03 6f 72
+ 67 00 c0 69 00 05 00 01 00 00 54 60 00 02 c0 69
+
diff --git a/src/lib/cache/tests/testdata/message_fromWire8 b/src/lib/cache/tests/testdata/message_fromWire8
new file mode 100644
index 0000000..bc9e144
--- /dev/null
+++ b/src/lib/cache/tests/testdata/message_fromWire8
@@ -0,0 +1,23 @@
+# A response includes multiple DNAME and synchronized CNAME records
+# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 900
+# ;; flags: qr aa rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
+# ;; WARNING: recursion requested but not available
+#
+# ;; QUESTION SECTION:
+# ;a.dname.example.com. IN NS
+#
+# ;; ANSWER SECTION:
+# dname.example.com. 21600 IN DNAME dname.example.org.
+# a.dname.example.com. 21600 IN CNAME a.dname.example.org.
+# dname.example.org. 21600 IN DNAME dname.example.org.
+# a.dname.example.org. 21600 IN CNAME a.dname.example.org.
+0384 8500
+ 00 01 00 04 00 00 00 00 01 61 05 64
+ 6e 61 6d 65 07 65 78 61 6d 70 6c 65 03 63 6f 6d
+ 00 00 02 00 01 c0 0e 00 27 00 01 00 00 54 60 00
+ 13 05 64 6e 61 6d 65 07 65 78 61 6d 70 6c 65 03
+ 6f 72 67 00 c0 0c 00 05 00 01 00 00 54 60 00 04
+ 01 61 c0 31 c0 31 00 27 00 01 00 00 54 60 00 13
+ 05 64 6e 61 6d 65 07 65 78 61 6d 70 6c 65 03 6f
+ 72 67 00 c0 50 00 05 00 01 00 00 54 60 00 02 c0
+ 50
More information about the bind10-changes
mailing list