From: Marcin Siodelski Date: Wed, 4 Jun 2014 16:57:51 +0000 (+0200) Subject: [3405] LeaseMgr is not started until server is configured. X-Git-Tag: trac3434_base~11^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5eed3a0c86ebc8a6dcc3defb8c3248a860a2e23e;p=thirdparty%2Fkea.git [3405] LeaseMgr is not started until server is configured. 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. --- diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 0f41447ad8..21c54d8e9c 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -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 diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index d5e69df615..3dfc3c3a67 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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 */)); diff --git a/src/bin/dhcp4/dhcp4_srv.h b/src/bin/dhcp4/dhcp4_srv.h index 0a0441aac5..a8f30d7d67 100644 --- a/src/bin/dhcp4/dhcp4_srv.h +++ b/src/bin/dhcp4/dhcp4_srv.h @@ -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); diff --git a/src/bin/dhcp4/tests/d2_unittest.h b/src/bin/dhcp4/tests/d2_unittest.h index 7de6b8fbea..2ad411a67b 100644 --- a/src/bin/dhcp4/tests/d2_unittest.h +++ b/src/bin/dhcp4/tests/d2_unittest.h @@ -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. diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 4a5b0236d7..3fb6eeb0f3 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -401,8 +401,8 @@ TEST_F(Dhcpv4SrvTest, basic) { // Check that the base class can be instantiated boost::scoped_ptr 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 diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.h b/src/bin/dhcp4/tests/dhcp4_test_utils.h index b978979c02..45dbb37bab 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.h +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -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")));