Kea
1.9.9-git
|
Concrete implementation of a lease database backend using flat file. More...
#include <memfile_lease_mgr.h>
Public Types | |
enum | Universe { V4, V6 } |
Specifies universe (V4, V6) More... | |
Public Member Functions | |
virtual void | commit () |
Commit Transactions. More... | |
virtual std::string | getDescription () const |
Returns description of the backend. More... | |
virtual std::string | getName () const |
Returns backend name. More... | |
virtual std::string | getType () const |
Return backend type. More... | |
virtual std::pair< uint32_t, uint32_t > | getVersion () const |
Returns backend version. More... | |
virtual void | rollback () |
Rollback Transactions. More... | |
virtual LeaseStatsQueryPtr | startLeaseStatsQuery4 () |
Creates and runs the IPv4 lease stats query. More... | |
virtual LeaseStatsQueryPtr | startLeaseStatsQuery6 () |
Creates and runs the IPv6 lease stats query. More... | |
virtual LeaseStatsQueryPtr | startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id) |
Creates and runs the IPv4 lease stats query for a single subnet. More... | |
virtual LeaseStatsQueryPtr | startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id) |
Creates and runs the IPv6 lease stats query for a single subnet. More... | |
virtual LeaseStatsQueryPtr | startSubnetRangeLeaseStatsQuery4 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) |
Creates and runs the IPv4 lease stats query for a single subnet. More... | |
virtual LeaseStatsQueryPtr | startSubnetRangeLeaseStatsQuery6 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) |
Creates and runs the IPv6 lease stats query for a single subnet. More... | |
Miscellaneous public convenience methods. | |
The following methods allow for retrieving useful information about the state of the backend. | |
std::string | getDefaultLeaseFilePath (Universe u) const |
Returns default path to the lease file. More... | |
std::string | getLeaseFilePath (Universe u) const |
Returns an absolute path to the lease file. More... | |
bool | persistLeases (Universe u) const |
Specifies whether or not leases are written to disk. More... | |
Public methods to retrieve information about the LFC process state. | |
These methods are meant to be used by unit tests to retrieve the state of the spawned LFC process before validating the result of the lease file cleanup. | |
bool | isLFCRunning () const |
Checks if the process performing lease file cleanup is running. More... | |
int | getLFCExitStatus () const |
Returns the status code returned by the last executed LFC process. More... | |
Public Member Functions inherited from isc::dhcp::LeaseMgr | |
LeaseMgr () | |
Constructor. More... | |
virtual | ~LeaseMgr () |
Destructor. More... | |
Lease6Ptr | getLease6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const |
returns zero or one IPv6 lease for a given duid+iaid+subnet_id More... | |
void | recountLeaseStats4 () |
Recalculates per-subnet and global stats for IPv4 leases. More... | |
void | recountLeaseStats6 () |
Recalculates per-subnet and global stats for IPv6 leases. More... | |
Static Public Attributes | |
static const int | MAJOR_VERSION = 2 |
static const int | MINOR_VERSION = 1 |
Defines minor version of the memfile backend. More... | |
Protected Member Functions | |
Protected methods used for Lease File Cleanup. | |
The following methods are protected so as they can be accessed and tested by unit tests. | |
virtual void | lfcCallback () |
A callback function triggering Lease File Cleanup (LFC). More... | |
Methods implementing the API of the lease database backend. | |
The following methods are implementing the API of the | |
Memfile_LeaseMgr (const db::DatabaseConnection::ParameterMap ¶meters) | |
The sole lease manager constructor. More... | |
virtual | ~Memfile_LeaseMgr () |
Destructor (closes file) More... | |
virtual bool | addLease (const Lease4Ptr &lease) |
Adds an IPv4 lease. More... | |
virtual bool | addLease (const Lease6Ptr &lease) |
Adds an IPv6 lease. More... | |
virtual Lease4Ptr | getLease4 (const isc::asiolink::IOAddress &addr) const |
Returns existing IPv4 lease for specified IPv4 address. More... | |
virtual Lease4Collection | getLease4 (const isc::dhcp::HWAddr &hwaddr) const |
Returns existing IPv4 leases for specified hardware address. More... | |
virtual Lease4Ptr | getLease4 (const HWAddr &hwaddr, SubnetID subnet_id) const |
Returns existing IPv4 lease for specified hardware address and a subnet. More... | |
virtual Lease4Collection | getLease4 (const ClientId &client_id) const |
Returns existing IPv4 lease for specified client-id. More... | |
virtual Lease4Ptr | getLease4 (const ClientId &clientid, SubnetID subnet_id) const |
Returns existing IPv4 lease for specified client-id. More... | |
virtual Lease4Collection | getLeases4 (SubnetID subnet_id) const |
Returns all IPv4 leases for the particular subnet identifier. More... | |
virtual Lease4Collection | getLeases4 (const std::string &hostname) const |
Returns all IPv4 leases for the particular hostname. More... | |
virtual Lease4Collection | getLeases4 () const |
Returns all IPv4 leases. More... | |
virtual Lease4Collection | getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const |
Returns range of IPv4 leases using paging. More... | |
virtual Lease6Ptr | getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const |
Returns existing IPv6 lease for a given IPv6 address. More... | |
virtual Lease6Collection | getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const |
Returns existing IPv6 lease for a given DUID + IA + lease type combination. More... | |
virtual Lease6Collection | getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const |
Returns existing IPv6 lease for a given DUID + IA + subnet-id + lease type combination. More... | |
virtual Lease6Collection | getLeases6 (SubnetID subnet_id) const |
Returns all IPv6 leases for the particular subnet identifier. More... | |
virtual Lease6Collection | getLeases6 (const std::string &hostname) const |
Returns all IPv6 leases for the particular hostname. More... | |
virtual Lease6Collection | getLeases6 () const |
Returns all IPv6 leases. More... | |
virtual Lease6Collection | getLeases6 (const DUID &duid) const |
Returns IPv6 leases for the DUID. More... | |
virtual Lease6Collection | getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const |
Returns range of IPv6 leases using paging. More... | |
virtual void | getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const |
Returns a collection of expired DHCPv4 leases. More... | |
virtual void | getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const |
Returns a collection of expired DHCPv6 leases. More... | |
virtual void | updateLease4 (const Lease4Ptr &lease4) |
Updates IPv4 lease. More... | |
virtual void | updateLease6 (const Lease6Ptr &lease6) |
Updates IPv6 lease. More... | |
virtual bool | deleteLease (const Lease4Ptr &lease) |
Deletes an IPv4 lease. More... | |
virtual bool | deleteLease (const Lease6Ptr &lease) |
Deletes an IPv6 lease. More... | |
virtual uint64_t | deleteExpiredReclaimedLeases4 (const uint32_t secs) |
Deletes all expired-reclaimed DHCPv4 leases. More... | |
virtual uint64_t | deleteExpiredReclaimedLeases6 (const uint32_t secs) |
Deletes all expired-reclaimed DHCPv6 leases. More... | |
virtual size_t | wipeLeases4 (const SubnetID &subnet_id) |
Removes specified IPv4 leases. More... | |
virtual size_t | wipeLeases6 (const SubnetID &subnet_id) |
Removed specified IPv6 leases. More... | |
static std::string | getDBVersion () |
Local version of getDBVersion() class method. More... | |
Public type and method used to determine file names for LFC. | |
enum | LFCFileType { FILE_CURRENT, FILE_INPUT, FILE_PREVIOUS, FILE_OUTPUT, FILE_FINISH, FILE_PID } |
Types of the lease files used by the Lease File Cleanup. More... | |
static std::string | appendSuffix (const std::string &file_name, const LFCFileType &file_type) |
Appends appropriate suffix to the file name. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from isc::dhcp::LeaseMgr | |
static std::string | getDBVersion () |
Class method to return extended version info This class method must be redeclared and redefined in derived classes. More... | |
static isc::asiolink::IOServicePtr & | getIOService () |
Returns pointer to the IO service. More... | |
static void | setIOService (const isc::asiolink::IOServicePtr &io_service) |
Sets IO service to be used by the Lease Manager. More... | |
Concrete implementation of a lease database backend using flat file.
This class implements a lease database backend using CSV files to store DHCPv4 and DHCPv6 leases on disk. The format of the files is determined by the CSVLeaseFile4
and CSVLeaseFile6
classes.
In order to obtain good performance, the backend stores leases incrementally, i.e. updates to leases are appended at the end of the lease file. To record the deletion of a lease, the lease record is appended to the lease file with the valid lifetime set to 0. However, this may result in a significant growth of the lease file size over time, because the lease file will contain many entries for each lease. In order to mitigate this problem, the backend implements the Lease File Cleanup mechanism which is described on the Kea wiki: https://gitlab.isc.org/isc-projects/kea/wikis/designs/Lease-File-Cleanup-design.
The backend installs an asiolink::IntervalTimer
to periodically execute the Memfile_LeaseMgr::lfcCallback
. This callback function controls the startup of the background process which removes redundant information from the lease file(s).
When the backend is starting up, it reads leases from the lease file (one by one) and adds them to the in-memory container as follows:
After the container holding leases is initialized, each subsequent update, removal or addition of the lease is appended to the lease file synchronously.
Originally, the Memfile backend didn't write leases to disk. This was particularly useful for testing server performance in non-disk bound conditions. In order to preserve this capability, the new parameter "persist=true|false" has been introduced in the database access string. For example, database access string: "type=memfile persist=true" enables writes of leases to a disk.
The lease file locations can be specified with the "name=[path]" parameter in the database access string. The [path] is the absolute path to the file (including file name). If this parameter is not specified, the default location in the installation directory is used: <install-dir>/var/lib/kea/kea-leases4.csv and <install-dir>/var/lib/kea/kea-leases6.csv.
Definition at line 79 of file memfile_lease_mgr.h.
Types of the lease files used by the Lease File Cleanup.
This enumeration is used by a method which appends the appropriate suffix to the lease file name.
Enumerator | |
---|---|
FILE_CURRENT |
Lease File |
FILE_INPUT |
Lease File Copy |
FILE_PREVIOUS |
Previous Lease File. |
FILE_OUTPUT |
LFC Output File. |
FILE_FINISH |
LFC Finish File. |
FILE_PID |
PID File. |
Definition at line 849 of file memfile_lease_mgr.h.
Specifies universe (V4, V6)
This enumeration is used by various functions in Memfile Lease Manager, to identify the lease type referred to. In particular, it is used by functions operating on the lease files to distinguish between lease files for DHCPv4 and DHCPv6.
Enumerator | |
---|---|
V4 | |
V6 |
Definition at line 106 of file memfile_lease_mgr.h.
isc::dhcp::Memfile_LeaseMgr::Memfile_LeaseMgr | ( | const db::DatabaseConnection::ParameterMap & | parameters | ) |
The sole lease manager constructor.
This method:
If any of the files loaded require conversion to the current schema (upgrade or downgrade), lfcSetup()
will be invoked with its run_once_now
parameter set to true. This causes lfcSetup() to invoke the LFC process immediately regardless of whether LFC is enabled. This ensures that any files which need conversion are converted automatically.
dbconfig is a generic way of passing parameters. Parameters are passed in the "name=value" format, separated by spaces. Values may be enclosed in double quotes, if needed.
parameters | A data structure relating keywords and values concerned with the database. |
Definition at line 631 of file memfile_lease_mgr.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES, isc::dhcp::DHCPSRV_MEMFILE_NO_STORAGE, isc::db::DatabaseConnection::getParameter(), LOG_WARN, MAJOR_VERSION, MINOR_VERSION, persistLeases(), V4, and V6.
|
virtual |
Destructor (closes file)
Definition at line 670 of file memfile_lease_mgr.cc.
|
virtual |
Adds an IPv4 lease.
lease | lease to be added |
Implements isc::dhcp::LeaseMgr.
Definition at line 713 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR4, and LOG_DEBUG.
|
virtual |
Adds an IPv6 lease.
lease | lease to be added |
Implements isc::dhcp::LeaseMgr.
Definition at line 749 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR6, and LOG_DEBUG.
|
static |
Appends appropriate suffix to the file name.
The suffix is selected using the LFC file type specified as a parameter. Each file type uses a unique suffix or no suffix:
See https://gitlab.isc.org/isc-projects/kea/wikis/designs/Lease-File-Cleanup-design for details.
file_name | A base file name to which suffix is appended. |
file_type | An LFC file type. |
Definition at line 1670 of file memfile_lease_mgr.cc.
References FILE_FINISH, FILE_INPUT, FILE_OUTPUT, FILE_PID, and FILE_PREVIOUS.
Referenced by isc::dhcp::LFCSetup::setup().
|
virtual |
Commit Transactions.
Commits all pending database operations. On databases that don't support transactions, this is a no-op.
Implements isc::dhcp::LeaseMgr.
Definition at line 1659 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_COMMIT, and LOG_DEBUG.
|
virtual |
Deletes all expired-reclaimed DHCPv4 leases.
secs | Number of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1555 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4, LOG_DEBUG, and V4.
|
virtual |
Deletes all expired-reclaimed DHCPv6 leases.
secs | Number of seconds since expiration of leases before they can be removed. Leases which have expired later than this time will not be deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1573 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED6, LOG_DEBUG, and V6.
|
virtual |
Deletes an IPv4 lease.
lease | IPv4 lease being deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1500 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, and LOG_DEBUG.
Referenced by wipeLeases4(), and wipeLeases6().
|
virtual |
Deletes an IPv6 lease.
lease | IPv6 lease being deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1542 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR, and LOG_DEBUG.
|
static |
Local version of getDBVersion() class method.
Definition at line 682 of file memfile_lease_mgr.cc.
References MAJOR_VERSION, and MINOR_VERSION.
Referenced by isc::dhcp::Dhcpv6Srv::getVersion(), and isc::dhcp::Dhcpv4Srv::getVersion().
std::string isc::dhcp::Memfile_LeaseMgr::getDefaultLeaseFilePath | ( | Universe | u | ) | const |
Returns default path to the lease file.
u | Universe (V4 or V6). |
Definition at line 1698 of file memfile_lease_mgr.cc.
References isc::dhcp::CfgMgr::getDataDir(), isc::dhcp::CfgMgr::instance(), and V4.
|
virtual |
Returns description of the backend.
This description may be multiline text that describes the backend.
Implements isc::dhcp::LeaseMgr.
Definition at line 1654 of file memfile_lease_mgr.cc.
|
virtual |
Returns a collection of expired DHCPv4 leases.
This method returns at most max_leases
expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.
[out] | expired_leases | A container to which expired leases returned by the database backend are added. |
max_leases | A maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1327 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED4, and LOG_DEBUG.
|
virtual |
Returns a collection of expired DHCPv6 leases.
This method returns at most max_leases
expired leases. The leases returned haven't been reclaimed, i.e. the database query must exclude reclaimed leases from the results returned.
[out] | expired_leases | A container to which expired leases returned by the database backend are added. |
max_leases | A maximum number of leases to be returned. If this value is set to 0, all expired (but not reclaimed) leases are returned. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1363 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED6, and LOG_DEBUG.
|
virtual |
Returns existing IPv4 lease for specified IPv4 address.
This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.
addr | An address of the searched lease. |
Implements isc::dhcp::LeaseMgr.
Definition at line 773 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR4, LOG_DEBUG, and isc::asiolink::IOAddress::toText().
|
virtual |
Returns existing IPv4 leases for specified hardware address.
Although in the usual case there will be only one lease, for mobile clients or clients with multiple static/fixed/reserved leases there can be more than one. Thus return type is a container, not a single pointer.
hwaddr | hardware address of the client |
Implements isc::dhcp::LeaseMgr.
Definition at line 802 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HWADDR, LOG_DEBUG, and isc::dhcp::HWAddr::toText().
|
virtual |
Returns existing IPv4 lease for specified hardware address and a subnet.
This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.
There can be at most one lease for a given HW address in a single pool, so this method with either return a single lease or NULL.
hwaddr | hardware address of the client |
subnet_id | identifier of the subnet that lease must belong to |
Implements isc::dhcp::LeaseMgr.
Definition at line 836 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_HWADDR, LOG_DEBUG, and isc::dhcp::HWAddr::toText().
|
virtual |
Returns existing IPv4 lease for specified client-id.
client_id | client identifier |
Implements isc::dhcp::LeaseMgr.
Definition at line 867 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_CLIENTID, LOG_DEBUG, and isc::dhcp::ClientId::toText().
|
virtual |
Returns existing IPv4 lease for specified client-id.
This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.
There can be at most one lease for a given HW address in a single pool, so this method with either return a single lease or NULL.
clientid | client identifier |
subnet_id | identifier of the subnet that lease must belong to |
Implements isc::dhcp::LeaseMgr.
Definition at line 900 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_CLIENTID, LOG_DEBUG, and isc::dhcp::ClientId::toText().
|
virtual |
Returns existing IPv6 lease for a given IPv6 address.
This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.
type | specifies lease type: (NA, TA or PD) |
addr | An address of the searched lease. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1051 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR6, LOG_DEBUG, isc::asiolink::IOAddress::toText(), and isc::dhcp::Lease::typeToText().
std::string isc::dhcp::Memfile_LeaseMgr::getLeaseFilePath | ( | Universe | u | ) | const |
Returns an absolute path to the lease file.
u | Universe (V4 or V6). |
Definition at line 1707 of file memfile_lease_mgr.cc.
References V4.
|
virtual |
Returns all IPv4 leases for the particular subnet identifier.
subnet_id | subnet identifier. |
Implements isc::dhcp::LeaseMgr.
Definition at line 928 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID4, and LOG_DEBUG.
|
virtual |
Returns all IPv4 leases for the particular hostname.
hostname | hostname in lower case. |
Implements isc::dhcp::LeaseMgr.
Definition at line 957 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME4, and LOG_DEBUG.
|
virtual |
Returns all IPv4 leases.
Implements isc::dhcp::LeaseMgr.
Definition at line 980 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET4, and LOG_DEBUG.
|
virtual |
Returns range of IPv4 leases using paging.
This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv4 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.
The typical usage of this method is as follows:
lower_bound_address | IPv4 address used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1015 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE4, isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
virtual |
Returns existing IPv6 lease for a given DUID + IA + lease type combination.
type | specifies lease type: (NA, TA or PD) |
duid | client DUID |
iaid | IA identifier |
Implements isc::dhcp::LeaseMgr.
Definition at line 1085 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_IAID_DUID, LOG_DEBUG, isc::dhcp::DUID::toText(), and isc::dhcp::Lease::typeToText().
|
virtual |
Returns existing IPv6 lease for a given DUID + IA + subnet-id + lease type combination.
This function returns a copy of the lease. The modification in the return lease does not affect the instance held in the lease storage.
type | specifies lease type: (NA, TA or PD) |
duid | client DUID |
iaid | IA identifier |
subnet_id | identifier of the subnet the lease must belong to |
Implements isc::dhcp::LeaseMgr.
Definition at line 1128 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID, LOG_DEBUG, isc::dhcp::DUID::toText(), and isc::dhcp::Lease::typeToText().
|
virtual |
Returns all IPv6 leases for the particular subnet identifier.
subnet_id | subnet identifier. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1164 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID6, and LOG_DEBUG.
|
virtual |
Returns all IPv6 leases for the particular hostname.
hostname | hostname in lower case. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1193 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME6, and LOG_DEBUG.
|
virtual |
Returns all IPv6 leases.
Implements isc::dhcp::LeaseMgr.
Definition at line 1216 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6, and LOG_DEBUG.
|
virtual |
Returns IPv6 leases for the DUID.
duid | client DUID |
Implements isc::dhcp::LeaseMgr.
Definition at line 1244 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6_DUID, LOG_DEBUG, and isc::dhcp::DUID::toText().
|
virtual |
Returns range of IPv6 leases using paging.
This method implements paged browsing of the lease database. The first parameter specifies a page size. The second parameter is optional and specifies the starting address of the range. This address is excluded from the returned range. The IPv6 zero address (default) denotes that the first page should be returned. There is no guarantee about the order of returned leases.
The typical usage of this method is as follows:
lower_bound_address | IPv6 address used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1280 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE6, isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
int isc::dhcp::Memfile_LeaseMgr::getLFCExitStatus | ( | ) | const |
Returns the status code returned by the last executed LFC process.
Definition at line 1836 of file memfile_lease_mgr.cc.
|
inlinevirtual |
Returns backend name.
For now, memfile can only store data in memory.
Implements isc::dhcp::LeaseMgr.
Definition at line 809 of file memfile_lease_mgr.h.
|
inlinevirtual |
Return backend type.
Returns the type of the backend.
Implements isc::dhcp::LeaseMgr.
Definition at line 800 of file memfile_lease_mgr.h.
|
inlinevirtual |
Returns backend version.
Implements isc::dhcp::LeaseMgr.
Definition at line 824 of file memfile_lease_mgr.h.
bool isc::dhcp::Memfile_LeaseMgr::isLFCRunning | ( | ) | const |
Checks if the process performing lease file cleanup is running.
Definition at line 1831 of file memfile_lease_mgr.cc.
|
protectedvirtual |
A callback function triggering Lease File Cleanup (LFC).
This method is executed periodically to start the lease file cleanup. It checks whether the file is a DHCPv4 lease file or DHCPv6 lease file and executes the Memfile_LeaseMgr::lfcExecute
private method with the appropriate parameters.
This method is virtual so as it can be overridden and customized in the unit tests. In particular, the unit test which checks that the callback function has been executed would override this function to increase the execution counter each time it is executed.
Definition at line 1841 of file memfile_lease_mgr.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_START, and LOG_INFO.
bool isc::dhcp::Memfile_LeaseMgr::persistLeases | ( | Universe | u | ) | const |
Specifies whether or not leases are written to disk.
It is possible that leases for DHCPv4 are written to disk whereas leases for DHCPv6 are not; or vice versa. The argument of the method specifies the type of lease in that respect.
u | Universe (V4 or V6). |
Definition at line 1716 of file memfile_lease_mgr.cc.
Referenced by Memfile_LeaseMgr().
|
virtual |
Rollback Transactions.
Rolls back all pending database operations. On databases that don't support transactions, this is a no-op.
Implements isc::dhcp::LeaseMgr.
Definition at line 1664 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ROLLBACK, and LOG_DEBUG.
|
virtual |
Creates and runs the IPv4 lease stats query.
It creates an instance of a MemfileLeaseStatsQuery4 for an all subnets query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1939 of file memfile_lease_mgr.cc.
|
virtual |
Creates and runs the IPv6 lease stats query.
It creates an instance of a MemfileLeaseStatsQuery6 and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1962 of file memfile_lease_mgr.cc.
|
virtual |
Creates and runs the IPv4 lease stats query for a single subnet.
It creates an instance of a MemfileLeaseStatsQuery4 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
subnet_id | id of the subnet for which stats are desired |
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1946 of file memfile_lease_mgr.cc.
|
virtual |
Creates and runs the IPv6 lease stats query for a single subnet.
It creates an instance of a MemfileLeaseStatsQuery6 for a single subnet query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
subnet_id | id of the subnet for which stats are desired |
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1969 of file memfile_lease_mgr.cc.
|
virtual |
Creates and runs the IPv4 lease stats query for a single subnet.
It creates an instance of a MemfileLeaseStatsQuery4 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
first_subnet_id | first subnet in the range of subnets |
last_subnet_id | last subnet in the range of subnets |
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1953 of file memfile_lease_mgr.cc.
|
virtual |
Creates and runs the IPv6 lease stats query for a single subnet.
It creates an instance of a MemfileLeaseStatsQuery6 for a subnet range query and then invokes its start method in which the query constructs its statistical data result set. The query object is then returned.
first_subnet_id | first subnet in the range of subnets |
last_subnet_id | last subnet in the range of subnets |
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 1976 of file memfile_lease_mgr.cc.
|
virtual |
Updates IPv4 lease.
lease4 | The lease to be updated. |
NoSuchLease | if there is no such lease to be updated. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1411 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR4, and LOG_DEBUG.
|
virtual |
Updates IPv6 lease.
lease6 | The lease to be updated. |
NoSuchLease | if there is no such lease to be updated. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1458 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR6, and LOG_DEBUG.
|
virtual |
Removes specified IPv4 leases.
This rather dangerous method is able to remove all leases from specified subnet.
subnet_id | identifier of the subnet |
Implements isc::dhcp::LeaseMgr.
Definition at line 1985 of file memfile_lease_mgr.cc.
References deleteLease(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES4, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES4_FINISHED, and LOG_INFO.
|
virtual |
Removed specified IPv6 leases.
This rather dangerous method is able to remove all leases from specified subnet.
subnet_id | identifier of the subnet |
Implements isc::dhcp::LeaseMgr.
Definition at line 2014 of file memfile_lease_mgr.cc.
References deleteLease(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES6, isc::dhcp::DHCPSRV_MEMFILE_WIPE_LEASES6_FINISHED, and LOG_INFO.