[svn] commit: r755 - in /branches/each-ds/src: bin/ bin/auth/ bin/bind10/ lib/auth/cpp/

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Feb 8 22:42:21 UTC 2010


Author: each
Date: Mon Feb  8 22:42:21 2010
New Revision: 755

Log:
checkpoint: copied over the changes from the each-datasrc branch,
but this time committed the branch *before* making changes, so that
svn could more easily generate a diff for review.

Removed:
    branches/each-ds/src/lib/auth/cpp/data_source_plot.cc
    branches/each-ds/src/lib/auth/cpp/data_source_plot.h
Modified:
    branches/each-ds/src/bin/Makefile.am
    branches/each-ds/src/bin/auth/auth.spec
    branches/each-ds/src/bin/auth/auth_srv.cc
    branches/each-ds/src/bin/auth/auth_srv.h
    branches/each-ds/src/bin/bind10/bind10.py.in
    branches/each-ds/src/lib/auth/cpp/data_source.cc
    branches/each-ds/src/lib/auth/cpp/data_source.h
    branches/each-ds/src/lib/auth/cpp/data_source_static.cc
    branches/each-ds/src/lib/auth/cpp/data_source_static.h

Modified: branches/each-ds/src/bin/Makefile.am
==============================================================================
--- branches/each-ds/src/bin/Makefile.am (original)
+++ branches/each-ds/src/bin/Makefile.am Mon Feb  8 22:42:21 2010
@@ -1,1 +1,1 @@
-SUBDIRS = bind10 bindctl cfgmgr msgq host cmdctl auth parkinglot
+SUBDIRS = bind10 bindctl cfgmgr msgq host cmdctl auth

Modified: branches/each-ds/src/bin/auth/auth.spec
==============================================================================
--- branches/each-ds/src/bin/auth/auth.spec (original)
+++ branches/each-ds/src/bin/auth/auth.spec Mon Feb  8 22:42:21 2010
@@ -1,6 +1,6 @@
 {
   "data_specification": {
-    "module_name": "ParkingLot"
+    "module_name": "Auth"
   }
 }
 

Modified: branches/each-ds/src/bin/auth/auth_srv.cc
==============================================================================
--- branches/each-ds/src/bin/auth/auth_srv.cc (original)
+++ branches/each-ds/src/bin/auth/auth_srv.cc Mon Feb  8 22:42:21 2010
@@ -66,6 +66,9 @@
         throw FatalError("could not bind socket");
 
     sock = s;
+
+    // add static data source
+    data_src.addDataSrc(new StaticDataSrc);
 }
 
 void

Modified: branches/each-ds/src/bin/auth/auth_srv.h
==============================================================================
--- branches/each-ds/src/bin/auth/auth_srv.h (original)
+++ branches/each-ds/src/bin/auth/auth_srv.h Mon Feb  8 22:42:21 2010
@@ -23,7 +23,6 @@
 class AuthSrv {
 public:
     explicit AuthSrv(int port);
-    //~AuthSrv() {}
     int getSocket() { return (sock); }
     void processMessage();
     void serve(std::string zone_name);
@@ -31,8 +30,7 @@
     isc::data::ElementPtr updateConfig(isc::data::ElementPtr config);
 private:
 
-    // TODO: make this a MetaDataSrc, but that one is abstract...
-    isc::dns::StaticDataSrc data_src;
+    isc::dns::MetaDataSrc data_src;
     int sock;
 };
 

Modified: branches/each-ds/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/each-ds/src/bin/bind10/bind10.py.in (original)
+++ branches/each-ds/src/bin/bind10/bind10.py.in Mon Feb  8 22:42:21 2010
@@ -194,7 +194,7 @@
         if self.verbose:
             print("[XX] ccsession started")
 
-        # start the parking lot
+        # start the auth server
         # XXX: this must be read from the configuration manager in the future
         # XXX: we hardcode port 5300
         if self.verbose:
@@ -233,7 +233,7 @@
         cmd = { "command": ['shutdown']}
         self.cc_session.group_sendmsg(cmd, 'Boss', 'Cmd-Ctrld')
         self.cc_session.group_sendmsg(cmd, "Boss", "ConfigManager")
-        self.cc_session.group_sendmsg(cmd, "Boss", "ParkingLot")
+        self.cc_session.group_sendmsg(cmd, "Boss", "Auth")
 
     def stop_process(self, process):
         """Stop the given process, friendly-like."""

Modified: branches/each-ds/src/lib/auth/cpp/data_source.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source.cc Mon Feb  8 22:42:21 2010
@@ -1,3 +1,5 @@
+#include <iostream>
+
 #include <dns/buffer.h>
 #include <dns/name.h>
 #include <dns/rrset.h>
@@ -18,11 +20,12 @@
 
     while (!q.tasks().empty()) {
         RRsetList data, sigs;
-        bool found = false;
         QueryTaskPtr task = q.tasks().front();
         q.tasks().pop();
 
-        const DataSrc* ds = findClosestEnclosure(task->qname, container, found);
+        NameMatch match(task->qname);
+        findClosestEnclosure(match);
+        const DataSrc* ds = match.bestDataSrc();
 
         if (ds == NULL) {
             result = ZONE_NOT_FOUND;

Modified: branches/each-ds/src/lib/auth/cpp/data_source.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source.h (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source.h Mon Feb  8 22:42:21 2010
@@ -21,6 +21,7 @@
 #include <dns/name.h>
 #include <dns/rrset.h>
 #include <auth/query.h>
+#include <iostream>
 
 namespace isc {
 namespace dns {
@@ -36,6 +37,7 @@
 };
 
 class DataSrc;
+class NameMatch;
 
 typedef std::vector<RRsetPtr> RRsetList;
 
@@ -60,17 +62,12 @@
                                const RRType& qtype,
                                RRsetList& target) const = 0;
 
-    virtual const DataSrc* findClosestEnclosure(const Name& qname,
-                                                Name& container,
-                                                bool& found) const = 0;
+    virtual void findClosestEnclosure(NameMatch& match) const = 0;
 
     // Optional 'low-level' methods.  These will have stub implementations
     // in the general DataSrc class but MAY be overwritten by subclasses
     virtual DSResult init() = 0;
     virtual DSResult close() = 0;
-
-    //virtual const RRClass& getClass() const = 0;
-    //virtual const RRClass& setClass() const = 0;
 };
 
 // Base class for a DNS Data Source
@@ -93,9 +90,30 @@
                                const RRType& qtype,
                                RRsetList& target) const = 0;
 
-    virtual const DataSrc* findClosestEnclosure(const Name& qname,
-                                                Name& container,
-                                                bool& found) const = 0;
+    virtual DSResult findAddrs(const Name& qname,
+                               const RRClass& qclass,
+                               RRsetList& target,
+                               RRsetList& sigs) const {
+        DSResult r;
+        r = findRRset(qname, qclass, RRType::A(), target, sigs);
+        if (r != SUCCESS)
+            return (r);
+        r = findRRset(qname, qclass, RRType::AAAA(), target, sigs);
+        return (r);
+    }
+
+    virtual DSResult findAddrs(const Name& qname,
+                               const RRClass& qclass,
+                               RRsetList& target) const {
+        DSResult r;
+        r = findRRset(qname, qclass, RRType::A(), target);
+        if (r != SUCCESS)
+            return (r);
+        r = findRRset(qname, qclass, RRType::AAAA(), target);
+        return (r);
+    }
+
+    virtual void findClosestEnclosure(NameMatch& match) const = 0;
 
     const RRClass& getClass() const { return rrclass; }
     void setClass(RRClass& c) { rrclass = c; }
@@ -119,31 +137,72 @@
         }
 
         data_sources.push_back(ds);
-    };
-
-    const DataSrc* findClosestEnclosure(const Name& qname,
-                                        Name& container,
-                                        bool& found) const
-    {
-        const DataSrc* best = NULL;
+    }
+
+    void findClosestEnclosure(NameMatch& match) const {
         BOOST_FOREACH (DataSrc* ds, data_sources) {
-            const DataSrc* source;
-
             if (getClass() != RRClass::ANY() && ds->getClass() != getClass()) {
                 continue;
             }
 
-            source = ds->findClosestEnclosure(qname, container, found);
-            if (source != NULL) {
-                best = source;
-            }
+            ds->findClosestEnclosure(match);
         }
-
-        return (best);
-    };
+    }
+
+    // Actual queries for data should not be sent to a MetaDataSrc object,
+    // so we return NOT_IMPLEMENTED if we receive any.
+    //
+    // Instead, use findClosestEnclosure() to get a pointer to the best
+    // concrete data source, then send all queries directly there.
+
+    DSResult findRRset(const Name& qname, const RRClass& qclass,
+                       const RRType& qtype, RRsetList& target,
+                       RRsetList& sigs) const {
+        return (NOT_IMPLEMENTED);
+    }
+
+    DSResult findRRset(const Name& qname, const RRClass& qclass,
+                       const RRType& qtype, RRsetList& target) const {
+        return (NOT_IMPLEMENTED);
+    }
+
+    DSResult findAddrs(const Name& qname, const RRClass& qclass,
+                       RRsetList& target, RRsetList& sigs) const {
+        return (NOT_IMPLEMENTED);
+    }
+
+    DSResult findAddrs(const Name& qname, const RRClass& qclass,
+                       RRsetList& target) const {
+        return (NOT_IMPLEMENTED);
+    }
 
 private:
     std::vector<DataSrc*> data_sources;
+};
+
+class NameMatch {
+public:
+    NameMatch(const Name& qname) :
+        closest_name_(NULL), best_source_(NULL), qname_(qname) {}
+
+    ~NameMatch() {}
+
+    void update(const DataSrc& new_source, const Name& container) {
+        if (closest_name_ == NULL ||
+            closest_name_->getLabelCount() < container.getLabelCount()) {
+            closest_name_ = &container;
+            best_source_ = &new_source;
+        }
+    }
+
+    const Name& qname() { return (qname_); }
+    const Name* closestName() { return (closest_name_); }
+    const DataSrc* bestDataSrc() { return (best_source_); }
+
+private:
+    const Name* closest_name_;
+    const DataSrc* best_source_;
+    const Name& qname_;
 };
 
 }

Modified: branches/each-ds/src/lib/auth/cpp/data_source_static.cc
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source_static.cc (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source_static.cc Mon Feb  8 22:42:21 2010
@@ -47,25 +47,25 @@
     version_ns->addRdata(generic::NS(version_name));
 }
 
-const DataSrc*
-StaticDataSrc::findClosestEnclosure(const Name& qname, Name& container, bool& found) const {
+void
+StaticDataSrc::findClosestEnclosure(NameMatch& match) const {
+    const Name& qname = match.qname();
+
     NameComparisonResult::NameRelation version_cmp = 
         qname.compare(version_name).getRelation();
 
     if (version_cmp == NameComparisonResult::EQUAL ||
         version_cmp == NameComparisonResult::SUBDOMAIN) {
-        NameComparisonResult::NameRelation sub_cmp = 
-           version_name.compare(container).getRelation();
+        if (match.closestName() == NULL) {
+            match.update(*this, version_name);
+        } else {
+            NameComparisonResult::NameRelation sub_cmp = 
+                version_name.compare(*match.closestName()).getRelation();
 
-        if (sub_cmp == NameComparisonResult::SUBDOMAIN) {
-            container = authors_name;
-            found = true;
-            return this;
-        } else if (!found && sub_cmp == NameComparisonResult::EQUAL) {
-            found = true;
-            return this;
-        } else {
-            return NULL;
+            if (sub_cmp == NameComparisonResult::EQUAL || 
+                sub_cmp == NameComparisonResult::SUBDOMAIN) {
+                match.update(*this, version_name);
+            }
         }
     }
 
@@ -74,22 +74,18 @@
 
     if (authors_cmp == NameComparisonResult::EQUAL ||
         authors_cmp == NameComparisonResult::SUBDOMAIN) {
-        NameComparisonResult::NameRelation sub_cmp = 
-            authors_name.compare(container).getRelation();
-
-        if (sub_cmp == NameComparisonResult::SUBDOMAIN) {
-            container = authors_name;
-            found = true;
-            return this;
-        } else if (!found && sub_cmp == NameComparisonResult::EQUAL) {
-            found = true;
-            return this;
+        if (match.closestName() == NULL) {
+            match.update(*this, authors_name);
         } else {
-            return NULL;
+            NameComparisonResult::NameRelation sub_cmp = 
+                authors_name.compare(*match.closestName()).getRelation();
+    
+            if (sub_cmp == NameComparisonResult::EQUAL || 
+                sub_cmp == NameComparisonResult::SUBDOMAIN) {
+                match.update(*this, authors_name);
+            }
         }
     }
-
-    return NULL;
 }
 
 DSResult

Modified: branches/each-ds/src/lib/auth/cpp/data_source_static.h
==============================================================================
--- branches/each-ds/src/lib/auth/cpp/data_source_static.h (original)
+++ branches/each-ds/src/lib/auth/cpp/data_source_static.h Mon Feb  8 22:42:21 2010
@@ -35,9 +35,7 @@
     StaticDataSrc();
     ~StaticDataSrc() {};
 
-    const DataSrc* findClosestEnclosure(const Name& qname,
-                                        Name& container,
-                                        bool& found) const;
+    void findClosestEnclosure(NameMatch& match) const;
 
     DSResult findRRset(const Name& qname,
                        const RRClass& qclass,




More information about the bind10-changes mailing list