BIND 10 master, updated. 55e0fb24720f98d51eeff77af6bdc0dff8649fa4 [master] Rename RRTTL::MAX() to MAX_TTL() to avoid shadowing

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Dec 18 10:29:54 UTC 2012


The branch, master has been updated
       via  55e0fb24720f98d51eeff77af6bdc0dff8649fa4 (commit)
       via  7454de81c9a382b84361fe8e35a19e1d04890141 (commit)
       via  5cd3fa2a026c0cfadffe57b6c859f8621c17c21f (commit)
       via  cecd1c59612f853434cea629f19a4b4a234da966 (commit)
       via  f5dc7406f61fb182aeed500fd39c1fd3b486d6c3 (commit)
       via  91455fb76e9acd98a1201f5e261896993e7a2339 (commit)
       via  757d91ff52158a17e9e17990aa39815fda2ed3f6 (commit)
       via  7400eee5cb287236717e78c8956cc09efb424813 (commit)
       via  88dd03a0064c14a1608b6be9e4cff5d5cee7643f (commit)
       via  8a49f520e191d8ff14d8118ec80ab5c83701995d (commit)
       via  c41a723a55a2d5665ee28716b32983ea17a38d97 (commit)
       via  1a7c1e3d9a33115839c64869a28f3c7daf63efc0 (commit)
       via  78688fbf0ddeb0f2e47a4988246b8ad29fe14ba4 (commit)
       via  7450f285f169e7ab894c5b85e303d1065795529e (commit)
       via  4643f0af180b2c360a53a8d47660a92332e48aa9 (commit)
       via  0333782cc1f51e1839e5cea59c72ef72a4b05929 (commit)
       via  1f339724101df031a6e5b0338bbd085132f0e1ac (commit)
       via  48a559472ac908be3bf697b11c01fb1a0fe13273 (commit)
      from  d2cc8db8c12a44199fdfcb5ffbcda82794c1c189 (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 55e0fb24720f98d51eeff77af6bdc0dff8649fa4
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Dec 18 15:20:51 2012 +0530

    [master] Rename RRTTL::MAX() to MAX_TTL() to avoid shadowing
    
    OpenBSD, NetBSD and some builds on MacOS don't like it.

commit 7454de81c9a382b84361fe8e35a19e1d04890141
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Dec 18 15:18:50 2012 +0530

    [master] Update .gitignore

commit 5cd3fa2a026c0cfadffe57b6c859f8621c17c21f
Merge: cecd1c5 d2cc8db
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Dec 18 14:56:33 2012 +0530

    Merge branch 'master' into trac2431_2
    
    Conflicts:
    	src/lib/dns/master_loader.cc

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/master_loader.cc                |   88 +++++++++++++++++----------
 src/lib/dns/rrttl.h                         |    2 +-
 src/lib/dns/tests/master_loader_unittest.cc |   69 +++++++++++++++++++++
 src/lib/dns/tests/rrttl_unittest.cc         |    2 +-
 src/lib/log/tests/.gitignore                |    2 +
 5 files changed, 130 insertions(+), 33 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 6190c7a..247b4c1 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -143,6 +143,56 @@ private:
         pushSource(filename);
     }
 
+    // A helper method for loadIncremental(). It parses part of an RR
+    // until it finds the RR type field.  If TTL or RR class is
+    // specified before the RR type, it also recognizes and validates
+    // them.  explicit_ttl will be set to true if this method finds a
+    // valid TTL field.
+    RRType parseRRParams(bool& explicit_ttl) {
+        // Find TTL, class and type.  Both TTL and class are
+        // optional and may occur in any order if they exist. TTL
+        // and class come before type which must exist.
+        //
+        // [<TTL>] [<class>] <type> <RDATA>
+        // [<class>] [<TTL>] <type> <RDATA>
+        MasterToken rrparam_token = lexer_.getNextToken(MasterToken::STRING);
+
+        // named-signzone outputs TTL first, so try parsing it in order
+        // first.
+        if (setCurrentTTL(rrparam_token.getString())) {
+            explicit_ttl = true;
+            rrparam_token = lexer_.getNextToken(MasterToken::STRING);
+        } else {
+            // If it's not a TTL here, continue and try again
+            // after the RR class below.
+        }
+
+        boost::scoped_ptr<RRClass> rrclass;
+        try {
+            rrclass.reset(new RRClass(rrparam_token.getString()));
+            rrparam_token = lexer_.getNextToken(MasterToken::STRING);
+        } catch (const InvalidRRClass&) {
+            // If it's not an rrclass here, use the zone's class.
+            rrclass.reset(new RRClass(zone_class_));
+        }
+
+        // If we couldn't parse TTL earlier in the stream (above), try
+        // again at current location.
+        if (!explicit_ttl &&
+            setCurrentTTL(rrparam_token.getString())) {
+            explicit_ttl = true;
+            rrparam_token = lexer_.getNextToken(MasterToken::STRING);
+        }
+
+        if (*rrclass != zone_class_) {
+            isc_throw(InternalException, "Class mismatch: " << *rrclass <<
+                      "vs. " << zone_class_);
+        }
+
+        // Return the current string token's value as the RRType.
+        return (RRType(rrparam_token.getString()));
+    }
+
     // Upper limit check when recognizing a specific TTL value from the
     // zone file ($TTL, the RR's TTL field, or the SOA minimum).  RFC2181
     // Section 8 limits the range of TTL values to 2^31-1 (0x7fffffff),
@@ -158,7 +208,7 @@ private:
     // RR and the lexer is positioned at the next line.  It's just for
     // calculating the accurate source line when callback is necessary.
     void limitTTL(RRTTL& ttl, bool post_parsing) {
-        if (ttl > RRTTL::MAX()) {
+        if (ttl > RRTTL::MAX_TTL()) {
             const size_t src_line = lexer_.getSourceLine() -
                 (post_parsing ? 1 : 0);
             callbacks_.warning(lexer_.getSourceName(), src_line,
@@ -366,46 +416,22 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
                 continue;
             }
 
-            const Name name(name_string.beg, name_string.len,
-                            &zone_origin_);
-            // TODO: Some more flexibility. We don't allow omitting
-            // anything yet
+            const Name name(name_string.beg, name_string.len, &zone_origin_);
 
             // The parameters
-            MasterToken rrparam_token = lexer_.getNextToken();
-
             bool explicit_ttl = false;
-            if (rrparam_token.getType() == MasterToken::STRING) {
-                // Try TTL
-                if (setCurrentTTL(rrparam_token.getString())) {
-                    explicit_ttl = true;
-                    rrparam_token = lexer_.getNextToken();
-                }
-            }
-
-            const RRClass rrclass(rrparam_token.getString());
-            const RRType rrtype(getString());
-
-            // TODO: Some more validation?
-            if (rrclass != zone_class_) {
-                // It doesn't really matter much what type of exception
-                // we throw, we catch it just below.
-                isc_throw(isc::BadValue, "Class mismatch: " << rrclass <<
-                          "vs. " << zone_class_);
-            }
+            const RRType rrtype = parseRRParams(explicit_ttl);
             // TODO: Check if it is SOA, it should be at the origin.
 
-            const rdata::RdataPtr rdata(rdata::createRdata(rrtype, rrclass,
-                                                           lexer_,
-                                                           &zone_origin_,
-                                                           options_,
-                                                           callbacks_));
+            const rdata::RdataPtr rdata =
+                rdata::createRdata(rrtype, zone_class_, lexer_, &zone_origin_,
+                                   options_, callbacks_);
             // In case we get NULL, it means there was error creating
             // the Rdata. The errors should have been reported by
             // callbacks_ already. We need to decide if we want to continue
             // or not.
             if (rdata) {
-                add_callback_(name, rrclass, rrtype,
+                add_callback_(name, zone_class_, rrtype,
                               getCurrentTTL(explicit_ttl, rrtype, rdata),
                               rdata);
 
diff --git a/src/lib/dns/rrttl.h b/src/lib/dns/rrttl.h
index e160a1e..7904d84 100644
--- a/src/lib/dns/rrttl.h
+++ b/src/lib/dns/rrttl.h
@@ -293,7 +293,7 @@ public:
     ///
     /// \note At the moment an RRTTL object can have a value larger than
     /// this limit.  We may revisit it in a future version.
-    static const RRTTL& MAX() {
+    static const RRTTL& MAX_TTL() {
         static const RRTTL max_ttl(0x7fffffff);
         return (max_ttl);
     }
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 306936f..8c5f14d 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -280,6 +280,45 @@ struct ErrorCase {
     { "www      FORTNIGHT   IN  A   192.0.2.1", NULL, "Invalid TTL" },
     { "www      3600    XX  A   192.0.2.1", NULL, "Invalid class" },
     { "www      3600    IN  A   bad_ip", NULL, "Invalid Rdata" },
+
+    // Parameter ordering errors
+    { "www      IN      A   3600 192.168.2.7",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Incorrect order of class, TTL and type" },
+    { "www      A       IN  3600 192.168.2.8",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Incorrect order of class, TTL and type" },
+    { "www      3600    A   IN   192.168.2.7",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Incorrect order of class, TTL and type" },
+    { "www      A       3600 IN  192.168.2.8",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Incorrect order of class, TTL and type" },
+
+    // Missing type and Rdata
+    { "www", "unexpected end of input", "Missing type and Rdata" },
+    { "www 3600", "unexpected end of input", "Missing type and Rdata" },
+    { "www IN", "unexpected end of input", "Missing type and Rdata" },
+    { "www 3600 IN", "unexpected end of input", "Missing type and Rdata" },
+    { "www IN 3600", "unexpected end of input", "Missing type and Rdata" },
+
+    // Missing Rdata
+    { "www A",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Missing Rdata" },
+    { "www 3600 A",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Missing Rdata" },
+    { "www IN A",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Missing Rdata" },
+    { "www 3600 IN A",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Missing Rdata" },
+    { "www IN 3600 A",
+      "createRdata from text failed: IN/A RDATA construction from text failed",
+      "Missing Rdata" },
+
     { "www      3600    IN", NULL, "Unexpected EOLN" },
     { "www      3600    CH  TXT nothing", NULL, "Class mismatch" },
     { "www      \"3600\"  IN  A   192.0.2.1", NULL, "Quoted TTL" },
@@ -473,6 +512,36 @@ TEST_F(MasterLoaderTest, ttlFromPrevious) {
     checkCallbackMessage(warnings_.at(0), "using RFC1035 TTL semantics", 2);
 }
 
+TEST_F(MasterLoaderTest, RRParamsOrdering) {
+    // We test the order and existence of TTL, class and type. See
+    // MasterLoader::MasterLoaderImpl::parseRRParams() for ordering.
+
+    stringstream zone_stream;
+    // <TTL> <class> <type> <RDATA>
+    zone_stream << "a.example.org. 1800 IN A 192.0.2.1\n";
+    // <type> <RDATA>
+    zone_stream << "b.example.org. A 192.0.2.2\n";
+    // <class> <TTL> <type> <RDATA>
+    zone_stream << "c.example.org. IN 3600 A 192.0.2.3\n";
+    // <TTL> <type> <RDATA>
+    zone_stream << "d.example.org. 7200 A 192.0.2.4\n";
+    // <class> <type> <RDATA>
+    zone_stream << "e.example.org. IN A 192.0.2.5\n";
+
+    setLoader(zone_stream, Name("example.org."), RRClass::IN(),
+              MasterLoader::DEFAULT);
+    loader_->load();
+    EXPECT_TRUE(loader_->loadedSucessfully());
+    checkRR("a.example.org", RRType::A(), "192.0.2.1", RRTTL(1800));
+    checkRR("b.example.org", RRType::A(), "192.0.2.2", RRTTL(1800));
+    checkRR("c.example.org", RRType::A(), "192.0.2.3", RRTTL(3600));
+    checkRR("d.example.org", RRType::A(), "192.0.2.4", RRTTL(7200));
+    checkRR("e.example.org", RRType::A(), "192.0.2.5", RRTTL(7200));
+
+    EXPECT_EQ(1, warnings_.size());
+    checkCallbackMessage(warnings_.at(0), "using RFC1035 TTL semantics", 2);
+}
+
 TEST_F(MasterLoaderTest, ttlFromPreviousSOA) {
     // Mixture of the previous two cases: SOA has explicit TTL, followed by
     // an RR without an explicit TTL.  In this case the minimum TTL won't be
diff --git a/src/lib/dns/tests/rrttl_unittest.cc b/src/lib/dns/tests/rrttl_unittest.cc
index 916f720..8897102 100644
--- a/src/lib/dns/tests/rrttl_unittest.cc
+++ b/src/lib/dns/tests/rrttl_unittest.cc
@@ -266,7 +266,7 @@ TEST_F(RRTTLTest, gthan) {
 }
 
 TEST_F(RRTTLTest, maxTTL) {
-    EXPECT_EQ((1u << 31) - 1, RRTTL::MAX().getValue());
+    EXPECT_EQ((1u << 31) - 1, RRTTL::MAX_TTL().getValue());
 }
 
 // test operator<<.  We simply confirm it appends the result of toText().
diff --git a/src/lib/log/tests/.gitignore b/src/lib/log/tests/.gitignore
index b0e45b9..e7e12d6 100644
--- a/src/lib/log/tests/.gitignore
+++ b/src/lib/log/tests/.gitignore
@@ -1,3 +1,5 @@
+/buffer_logger_test
+/buffer_logger_test.sh
 /console_test.sh
 /destination_test.sh
 /init_logger_test



More information about the bind10-changes mailing list