]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3405] LeaseMgr is not started until server is configured.
authorMarcin Siodelski <marcin@isc.org>
Wed, 4 Jun 2014 16:57:51 +0000 (18:57 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 4 Jun 2014 16:57:51 +0000 (18:57 +0200)
Starting lease manager in the server constructor implied the use of the
default memfile for a short period until the server is configured. The
default memfile configuration used the persistence (writing leases to disk)
which in many cases required root privileges. This caused some unit tests
to fail.

src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp4/tests/d2_unittest.h
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_test_utils.h

index 0f41447ad8b3ea267416696a81cc2a093bc5ad81..21c54d8e9c6c5d5bea710b646931f852bbab3b4a 100644 (file)
@@ -77,11 +77,6 @@ change is committed by the administrator.
 A debug message indicating that the DHCPv4 server has received an
 updated configuration from the BIND 10 configuration system.
 
-% DHCP4_DB_BACKEND_STARTED lease database started (type: %1, name: %2)
-This informational message is printed every time DHCPv4 server is started
-and gives both the type and name of the database being used to store
-lease and other information.
-
 % DHCP4_DDNS_REQUEST_SEND_FAILED failed sending a request to b10-dhcp-ddns, error: %1,  ncr: %2
 This error message indicates that DHCP4 server attempted to send a DDNS
 update reqeust to the DHCP-DDNS server.  This is most likely a configuration or
index d5e69df615de647675657fe7e1887e93f8697a93..3dfc3c3a675c6cc366aaf21571c3c4e60c91e222 100644 (file)
@@ -82,11 +82,11 @@ namespace dhcp {
 
 const std::string Dhcpv4Srv::VENDOR_CLASS_PREFIX("VENDOR_CLASS_");
 
-Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const char* dbconfig, const bool use_bcast,
+Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
                      const bool direct_response_desired)
-: shutdown_(true), alloc_engine_(), port_(port),
-    use_bcast_(use_bcast), hook_index_pkt4_receive_(-1),
-    hook_index_subnet4_select_(-1), hook_index_pkt4_send_(-1) {
+    : shutdown_(true), alloc_engine_(), port_(port),
+      use_bcast_(use_bcast), hook_index_pkt4_receive_(-1),
+      hook_index_subnet4_select_(-1), hook_index_pkt4_send_(-1) {
 
     LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_OPEN_SOCKET).arg(port);
     try {
@@ -112,12 +112,6 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const char* dbconfig, const bool use_bcast,
             IfaceMgr::instance().openSockets4(port_, use_bcast_, error_handler);
         }
 
-        // Instantiate LeaseMgr
-        LeaseMgrFactory::create(dbconfig);
-        LOG_INFO(dhcp4_logger, DHCP4_DB_BACKEND_STARTED)
-            .arg(LeaseMgrFactory::instance().getType())
-            .arg(LeaseMgrFactory::instance().getName());
-
         // Instantiate allocation engine
         alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100,
                                             false /* false = IPv4 */));
index 0a0441aac5c91c0674bb5a2a305f78b314d70e08..a8f30d7d67d0cca8b062fe576f76d4815f299f1a 100644 (file)
@@ -83,13 +83,10 @@ public:
     /// root privileges.
     ///
     /// @param port specifies port number to listen on
-    /// @param dbconfig Lease manager configuration string.  The default
-    ///        of the "memfile" manager is used for testing.
     /// @param use_bcast configure sockets to support broadcast messages.
     /// @param direct_response_desired specifies if it is desired to
     /// use direct V4 traffic.
     Dhcpv4Srv(uint16_t port = DHCP4_SERVER_PORT,
-              const char* dbconfig = "type=memfile universe=4",
               const bool use_bcast = true,
               const bool direct_response_desired = true);
 
index 7de6b8fbeacbe7015ed1933a671e3ce3f2d952f2..2ad411a67b8eec87c0570aca6df0216ea128b7b9 100644 (file)
@@ -36,7 +36,7 @@ public:
 
     /// @brief Constructor
     D2Dhcpv4Srv()
-        : Dhcpv4Srv(0, "type=memfile", false, false), error_count_(0) {
+        : Dhcpv4Srv(0, false, false), error_count_(0) {
     }
 
     /// @brief virtual Destructor.
index 4a5b0236d75837ae5daa95a9905c070f916df225..3fb6eeb0f3afb23bbeae969a3dc58888c03fcb1f 100644 (file)
@@ -401,8 +401,8 @@ TEST_F(Dhcpv4SrvTest, basic) {
 
     // Check that the base class can be instantiated
     boost::scoped_ptr<Dhcpv4Srv> srv;
-    ASSERT_NO_THROW(srv.reset(new Dhcpv4Srv(DHCP4_SERVER_PORT + 10000, "type=memfile",
-                                            false, false)));
+    ASSERT_NO_THROW(srv.reset(new Dhcpv4Srv(DHCP4_SERVER_PORT + 10000, false,
+                                            false)));
     srv.reset();
     // We have to close open sockets because further in this test we will
     // call the Dhcpv4Srv constructor again. This constructor will try to
index b978979c0256ddaceb296b7af54c8626421eddb1..45dbb37babfbe2bddb1f570d025a87fca9f0c993 100644 (file)
@@ -27,6 +27,7 @@
 #include <dhcp/pkt_filter_inet.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/lease.h>
+#include <dhcpsrv/lease_mgr_factory.h>
 #include <dhcp4/dhcp4_srv.h>
 #include <asiolink/io_address.h>
 #include <config/ccsession.h>
@@ -117,8 +118,10 @@ public:
     /// @param port port number to listen on; the default value 0 indicates
     /// that sockets should not be opened.
     NakedDhcpv4Srv(uint16_t port = 0)
-        : Dhcpv4Srv(port, "type=memfile universe=4 persist=false",
-                    false, false) {
+        : Dhcpv4Srv(port, false, false) {
+        // Create a default lease database backend.
+        std::string dbconfig = "type=memfile universe=4 persist=false";
+        isc::dhcp::LeaseMgrFactory::create(dbconfig);
         // Create fixed server id.
         server_id_.reset(new Option4AddrLst(DHO_DHCP_SERVER_IDENTIFIER,
                                             asiolink::IOAddress("192.0.3.1")));