BIND 10 trac2559, updated. 79f0d62ef03b3774a0b0c6237eff78af821bdbc4 [2559] Remove the temporary configuration of the lease database

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 15 15:42:04 UTC 2013


The branch, trac2559 has been updated
       via  79f0d62ef03b3774a0b0c6237eff78af821bdbc4 (commit)
       via  fdbba41a48cffe7efc185b8eb59fd3471aeb78d5 (commit)
       via  2b81c6b347116512da7c653b0ca542a04b82015a (commit)
      from  c61ae0fbbba155063ada04a08ec44f3dc27ab6bc (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 79f0d62ef03b3774a0b0c6237eff78af821bdbc4
Author: Stephen Morris <stephen at isc.org>
Date:   Tue Jan 15 15:40:42 2013 +0000

    [2559] Remove the temporary configuration of the lease database
    
    The DHCP6 server had the lease database configuration temporarily
    hard-coded.  With the introduction of database configuration
    parameters, that is no longer needed.

commit fdbba41a48cffe7efc185b8eb59fd3471aeb78d5
Author: Stephen Morris <stephen at isc.org>
Date:   Tue Jan 15 15:08:50 2013 +0000

    [2559] Make opening of the lease database an informational message

commit 2b81c6b347116512da7c653b0ca542a04b82015a
Author: Stephen Morris <stephen at isc.org>
Date:   Tue Jan 15 14:04:55 2013 +0000

    [2559] Changes to comments

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

Summary of changes:
 src/bin/dhcp6/ctrl_dhcp6_srv.cc           |    4 ++--
 src/bin/dhcp6/ctrl_dhcp6_srv.h            |    4 +---
 src/bin/dhcp6/dhcp6_srv.cc                |    8 +-------
 src/bin/dhcp6/dhcp6_srv.h                 |    5 +----
 src/bin/dhcp6/main.cc                     |   13 +------------
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |   11 ++++++++++-
 src/lib/dhcpsrv/dbaccess_parser.cc        |    4 ----
 src/lib/dhcpsrv/dhcpsrv_messages.mes      |   11 +++++++++--
 src/lib/dhcpsrv/lease_mgr_factory.cc      |    6 ++----
 src/lib/dhcpsrv/memfile_lease_mgr.cc      |    3 +--
 10 files changed, 28 insertions(+), 41 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc
index 8611365..e5679f1 100644
--- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc
+++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc
@@ -149,8 +149,8 @@ void ControlledDhcpv6Srv::disconnectSession() {
     IfaceMgr::instance().set_session_socket(IfaceMgr::INVALID_SOCKET, NULL);
 }
 
-ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port, const char* dbconfig)
-    : Dhcpv6Srv(port, dbconfig), cc_session_(NULL), config_session_(NULL) {
+ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
+    : Dhcpv6Srv(port), cc_session_(NULL), config_session_(NULL) {
     server_ = this; // remember this instance for use in callback
 }
 
diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.h b/src/bin/dhcp6/ctrl_dhcp6_srv.h
index ef1acab..d790463 100644
--- a/src/bin/dhcp6/ctrl_dhcp6_srv.h
+++ b/src/bin/dhcp6/ctrl_dhcp6_srv.h
@@ -41,9 +41,7 @@ public:
     /// @brief Constructor
     ///
     /// @param port UDP port to be opened for DHCP traffic
-    /// @param dbconfig Lease manager database configuration string
-    ControlledDhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT,
-                        const char* dbconfig = "type=memfile");
+    ControlledDhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT);
 
     /// @brief Destructor.
     ~ControlledDhcpv6Srv();
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index b90c33e..cb943ec 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -50,7 +50,7 @@ using namespace std;
 namespace isc {
 namespace dhcp {
 
-Dhcpv6Srv::Dhcpv6Srv(uint16_t port, const char* dbconfig)
+Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
     : alloc_engine_(), serverid_(), shutdown_(true) {
 
     LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
@@ -71,12 +71,6 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port, const char* dbconfig)
 
         setServerID();
 
-        // Instantiate LeaseMgr
-        LeaseMgrFactory::create(dbconfig);
-        LOG_INFO(dhcp6_logger, DHCP6_DB_BACKEND_STARTED)
-            .arg(LeaseMgrFactory::instance().getType())
-            .arg(LeaseMgrFactory::instance().getName());
-
         // Instantiate allocation engine
         alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
 
diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h
index 0f3e641..e546e4b 100644
--- a/src/bin/dhcp6/dhcp6_srv.h
+++ b/src/bin/dhcp6/dhcp6_srv.h
@@ -80,10 +80,7 @@ public:
     /// old or create new DUID.
     ///
     /// @param port port on will all sockets will listen
-    /// @param dbconfig Lease manager configuration string.  The default
-    ///        of the "memfile" manager is used for testing.
-    Dhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT,
-            const char* dbconfig = "type=memfile");
+    Dhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT);
 
     /// @brief Destructor. Used during DHCPv6 service shutdown.
     virtual ~Dhcpv6Srv();
diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc
index ced7422..d9a38e7 100644
--- a/src/bin/dhcp6/main.cc
+++ b/src/bin/dhcp6/main.cc
@@ -36,17 +36,6 @@ using namespace std;
 /// Dhcpv6Srv and other classes, see \ref dhcpv6Session.
 
 namespace {
-// @todo: Replace the next line by extraction from configuration parameters
-// This is the "dbconfig" string for the MySQL database.  It is likely
-// that a long-term solution will be to create the instance of the lease manager
-// somewhere other than the Dhcpv6Srv constructor, to give time to extract
-// the connection string from the configuration database.
-#ifdef HAVE_MYSQL
-const char* DBCONFIG = "type=mysql name=kea user=kea password=kea host=localhost";
-#else
-const char* DBCONFIG = "type=memfile";
-#endif
-
 const char* const DHCP6_NAME = "b10-dhcp6";
 
 void
@@ -115,7 +104,7 @@ main(int argc, char* argv[]) {
 
     int ret = EXIT_SUCCESS;
     try {
-        ControlledDhcpv6Srv server(port_number, DBCONFIG);
+        ControlledDhcpv6Srv server(port_number);
         if (!stand_alone) {
             try {
                 server.establishSession();
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index ee0c725..f6b9aa1 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -54,7 +54,16 @@ namespace {
 class NakedDhcpv6Srv: public Dhcpv6Srv {
     // "naked" Interface Manager, exposes internal members
 public:
-    NakedDhcpv6Srv(uint16_t port):Dhcpv6Srv(port) { }
+    NakedDhcpv6Srv(uint16_t port) : Dhcpv6Srv(port) {
+        // Open the "memfile" database for leases
+        std::string memfile = "type=memfile";
+        LeaseMgrFactory::create(memfile);
+    }
+
+    virtual ~NakedDhcpv6Srv() {
+        // Close the lease database
+        LeaseMgrFactory::destroy();
+    }
 
     using Dhcpv6Srv::processSolicit;
     using Dhcpv6Srv::processRequest;
diff --git a/src/lib/dhcpsrv/dbaccess_parser.cc b/src/lib/dhcpsrv/dbaccess_parser.cc
index e822e03..da7b799 100644
--- a/src/lib/dhcpsrv/dbaccess_parser.cc
+++ b/src/lib/dhcpsrv/dbaccess_parser.cc
@@ -46,7 +46,6 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
     // 2. Update the copy with the passed keywords.
     // 3. Perform validation checks on the updated keyword/value pairs.
     // 4. If all is OK, update the stored keyword/value pairs.
-    // 5. Construct the updated database access string.
 
     // 1. Take a copy of the stored keyword/value pairs.
     map<string, string> values_copy = values_;
@@ -72,9 +71,6 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) {
         isc_throw(BadValue, "unknown backend database type: " << dbtype);
     }
 
-    /// @todo Log a warning if the type is memfile and there are other keywords.
-    ///       This will be done when the module is moved to libdhcpsrv
-
     // 4. If all is OK, update the stored keyword/value pairs.
     values_ = values_copy;
 }
diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes
index cc8da23..4591ccc 100644
--- a/src/lib/dhcpsrv/dhcpsrv_messages.mes
+++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes
@@ -61,8 +61,8 @@ returned the specified IPv6 subnet when given the address hint specified
 as the address is within the subnet.
 
 % DHCPSRV_CLOSE_DB closing currently open %1 database
-This is a debug message, issues when the DHCP server closed the currently
-open lease database.  It is issued at program shutdown, and whenever
+This is a debug message, issued when the DHCP server closes the currently
+open lease database.  It is issued at program shutdown and whenever
 the database access parameters are changed: in the latter case, the
 server closes the currently open database, and opens a database using
 the new parameters.
@@ -150,6 +150,13 @@ lease from the memory file database for the specified address.
 A debug message issued when the server is attempting to update IPv6
 lease from the memory file database for the specified address.
 
+% DHCPSRV_MEMFILE_WARNING using early version of memfile - leases will be lost after a restart
+This warning message is issued when the 'memfile' lease database is
+opened.  The current version of memfile does not store anything
+to disk, so lease information will be lost in the event of a restart.
+Using this version of memfile in a production environment is NOT 
+recommended.
+
 % DHCPSRV_MYSQL_ADD_ADDR4 adding IPv4 lease with address %1
 A debug message issued when the server is about to add an IPv4 lease
 with the specified address to the MySQL backend database.
diff --git a/src/lib/dhcpsrv/lease_mgr_factory.cc b/src/lib/dhcpsrv/lease_mgr_factory.cc
index ad31d12..1a2e817 100644
--- a/src/lib/dhcpsrv/lease_mgr_factory.cc
+++ b/src/lib/dhcpsrv/lease_mgr_factory.cc
@@ -120,15 +120,13 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
     // Yes, check what it is.
 #ifdef HAVE_MYSQL
     if (parameters[type] == string("mysql")) {
-        LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MYSQL_DB)
-            .arg(redacted);
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted);
         getLeaseMgrPtr().reset(new MySqlLeaseMgr(parameters));
         return;
     }
 #endif
     if (parameters[type] == string("memfile")) {
-        LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_DB)
-            .arg(redacted);
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted);
         getLeaseMgrPtr().reset(new Memfile_LeaseMgr(parameters));
         return;
     }
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index 6b2c847..b3f69c8 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -21,8 +21,7 @@ using namespace isc::dhcp;
 
 Memfile_LeaseMgr::Memfile_LeaseMgr(const ParameterMap& parameters)
     : LeaseMgr(parameters) {
-    std::cout << "Warning: Using memfile database backend. It is usable for limited"
-              << " testing only. Leases will be lost after restart." << std::endl;
+    LOG_WARN(dhcpsrv_logger, DHCPSRV_MEMFILE_WARNING);
 }
 
 Memfile_LeaseMgr::~Memfile_LeaseMgr() {



More information about the bind10-changes mailing list