Commit 5eed3a0c authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[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.
parent be1fcdc6
......@@ -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
......@@ -82,9 +82,9 @@ 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),
: 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) {
......@@ -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
// Instantiate allocation engine
alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100,
false /* false = IPv4 */));
......@@ -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);
......@@ -36,7 +36,7 @@ public:
/// @brief Constructor
: Dhcpv4Srv(0, "type=memfile", false, false), error_count_(0) {
: Dhcpv4Srv(0, false, false), error_count_(0) {
/// @brief virtual Destructor.
......@@ -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,
// We have to close open sockets because further in this test we will
// call the Dhcpv4Srv constructor again. This constructor will try to
......@@ -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";
// Create fixed server id.
server_id_.reset(new Option4AddrLst(DHO_DHCP_SERVER_IDENTIFIER,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment