Kea 2.7.6
|
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 Types inherited from isc::dhcp::TrackingLeaseMgr | |
typedef std::function< void(LeasePtr)> | CallbackFn |
Type of a callback function invoked upon a lease insertion, update or deletion. | |
enum | CallbackType { TRACK_ADD_LEASE , TRACK_UPDATE_LEASE , TRACK_DELETE_LEASE } |
An enumeration differentiating between lease write operations. More... | |
Public Member Functions | |
virtual void | commit () override |
Commit Transactions. | |
virtual std::string | getDescription () const override |
Returns description of the backend. | |
virtual std::string | getName () const override |
Returns backend name. | |
virtual std::string | getType () const override |
Return backend type. | |
virtual std::pair< uint32_t, uint32_t > | getVersion (const std::string &timer_name=std::string()) const override |
Returns backend version. | |
virtual void | rollback () override |
Rollback Transactions. | |
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. | |
int | getLFCExitStatus () const |
Returns the status code returned by the last executed LFC process. | |
virtual LeaseStatsQueryPtr | startLeaseStatsQuery4 () override |
Creates and runs the IPv4 lease stats query. | |
virtual LeaseStatsQueryPtr | startPoolLeaseStatsQuery4 () override |
Creates and runs the IPv4 lease stats query for all subnets and pools. | |
virtual LeaseStatsQueryPtr | startSubnetLeaseStatsQuery4 (const SubnetID &subnet_id) override |
Creates and runs the IPv4 lease stats query for a single subnet. | |
virtual LeaseStatsQueryPtr | startSubnetRangeLeaseStatsQuery4 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override |
Creates and runs the IPv4 lease stats query for a single subnet. | |
virtual LeaseStatsQueryPtr | startLeaseStatsQuery6 () override |
Creates and runs the IPv6 lease stats query. | |
virtual LeaseStatsQueryPtr | startPoolLeaseStatsQuery6 () override |
Creates and runs the IPv6 lease stats query for all subnets and pools. | |
virtual LeaseStatsQueryPtr | startSubnetLeaseStatsQuery6 (const SubnetID &subnet_id) override |
Creates and runs the IPv6 lease stats query for a single subnet. | |
virtual LeaseStatsQueryPtr | startSubnetRangeLeaseStatsQuery6 (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) override |
Creates and runs the IPv6 lease stats query for a single subnet. | |
Public Member Functions inherited from isc::dhcp::TrackingLeaseMgr | |
bool | hasCallbacks () const |
Checks if any callbacks have been registered. | |
bool | isLocked (const LeasePtr &lease) |
Checks if the lease is locked. | |
void | registerCallback (CallbackType type, std::string owner, Lease::Type lease_type, CallbackFn callback_fn) |
Registers a callback function for all subnets. | |
void | registerCallback (CallbackType type, std::string owner, SubnetID subnet_id, Lease::Type lease_type, CallbackFn callback_fn) |
Registers a callback function for a subnet. | |
void | unregisterAllCallbacks () |
Unregisters all callbacks. | |
void | unregisterCallbacks (SubnetID subnet_id, Lease::Type lease_type) |
Unregisters all callbacks for a given subnet identifier. | |
Public Member Functions inherited from isc::dhcp::LeaseMgr | |
LeaseMgr () | |
Constructor. | |
virtual | ~LeaseMgr () |
Destructor. | |
bool | getExtendedInfoTablesEnabled () const |
Returns the setting indicating if lease6 extended info tables are enabled. | |
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 | |
void | recountLeaseStats4 () |
Recalculates per-subnet and global stats for IPv4 leases. | |
void | recountLeaseStats6 () |
Recalculates per-subnet and global stats for IPv6 leases. | |
void | setExtendedInfoTablesEnabled (const bool enabled) |
Modifies the setting whether the lease6 extended info tables are enabled. | |
Static Public Attributes | |
static const int | MAJOR_VERSION_V4 = 3 |
static const int | MAJOR_VERSION_V6 = 5 |
static const int | MINOR_VERSION_V4 = 0 |
the minor version of the v4 memfile backend | |
static const int | MINOR_VERSION_V6 = 0 |
the minor version of the v6 memfile backend | |
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). | |
Protected Member Functions inherited from isc::dhcp::TrackingLeaseMgr | |
TrackingLeaseMgr () | |
Constructor. | |
void | runCallbacks (CallbackType type, const LeasePtr &lease) |
Runs registered callbacks of the particular type. | |
void | runCallbacksForSubnetID (CallbackType type, SubnetID subnet_id, const LeasePtr &lease) |
Runs registered callbacks of the particular type for a subnet id. | |
void | trackAddLease (const LeasePtr &lease) |
Invokes the callbacks when a new lease is added. | |
void | trackDeleteLease (const LeasePtr &lease) |
Invokes the callbacks when a lease is deleted. | |
void | trackUpdateLease (const LeasePtr &lease) |
Invokes the callbacks when a lease is updated. | |
bool | tryLock (const LeasePtr &lease) |
Attempts to lock a lease. | |
void | unlock (const LeasePtr &lease) |
Attempts to unlock a lease. | |
Protected Member Functions inherited from isc::dhcp::LeaseMgr | |
virtual bool | addExtendedInfo6 (const Lease6Ptr &lease) |
Extract extended info from a lease6 and add it into tables. | |
void | setExtendedInfoTablesEnabled (const db::DatabaseConnection::ParameterMap ¶meters) |
Extended information / Bulk Lease Query shared interface. | |
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. | |
Miscellaneous public convenience methods. | |
The following methods allow for retrieving useful information about the state of the backend. | |
Lease6ExtendedInfoRelayIdTable | relay_id6_ |
stores IPv6 by-relay-id cross-reference table | |
Lease6ExtendedInfoRemoteIdTable | remote_id6_ |
stores IPv6 by-remote-id cross-reference table | |
boost::shared_ptr< CSVLeaseFile4 > | lease_file4_ |
Holds the pointer to the DHCPv4 lease file IO. | |
boost::shared_ptr< CSVLeaseFile6 > | lease_file6_ |
Holds the pointer to the DHCPv6 lease file IO. | |
std::string | getDefaultLeaseFilePath (Universe u) const |
Returns default path to the lease file. | |
std::string | getLeaseFilePath (Universe u) const |
Returns an absolute path to the lease file. | |
bool | persistLeases (Universe u) const |
Specifies whether or not leases are written to disk. | |
Private methods and members used for Lease File Cleanup. | |
virtual size_t | getClassLeaseCount (const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const override |
Returns the class lease count for a given class and lease type. | |
virtual void | recountClassLeases4 () override |
Recount the leases per class for V4 leases. | |
virtual void | recountClassLeases6 () override |
Recount the leases per class for V6 leases. | |
virtual void | clearClassLeaseCounts () override |
Clears the class-lease count map. | |
virtual Lease4Collection | getLeases4ByRelayId (const OptionBuffer &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0) override |
The following queries are used to fulfill Bulk Lease Query queries. | |
virtual Lease4Collection | getLeases4ByRemoteId (const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0) override |
Returns existing IPv4 leases with a given remote-id. | |
virtual Lease6Collection | getLeases6ByRelayId (const DUID &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override |
Returns existing IPv6 leases with a given relay-id. | |
virtual Lease6Collection | getLeases6ByRemoteId (const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) override |
Returns existing IPv6 leases with a given remote-id. | |
size_t | extractExtendedInfo4 (bool update, bool current) |
Extract extended info for v4 leases. | |
virtual size_t | upgradeExtendedInfo6 (const LeasePageSize &page_size) override |
Upgrade extended info (v6). | |
virtual void | wipeExtendedInfoTables6 () override |
Wipe extended info table (v6). | |
virtual size_t | byRelayId6size () const override |
Return the by-relay-id table size. | |
virtual size_t | byRemoteId6size () const override |
Return the by-remote-id table size. | |
virtual void | writeLeases4 (const std::string &filename) override |
Write V4 leases to a file. | |
virtual void | writeLeases6 (const std::string &filename) override |
Write V6 leases to a file. | |
virtual size_t | upgradeExtendedInfo4 (const LeasePageSize &page_size) override |
Upgrade extended info (v4). | |
static TrackingLeaseMgrPtr | factory (const isc::db::DatabaseConnection::ParameterMap ¶meters) |
Factory class method. | |
void | buildExtendedInfoTables6 () |
Extended information / Bulk Lease Query shared interface. | |
virtual void | deleteExtendedInfo6 (const isc::asiolink::IOAddress &addr) override |
Delete lease6 extended info from tables. | |
virtual void | addRelayId6 (const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id) override |
Add lease6 extended info into by-relay-id table. | |
virtual void | addRemoteId6 (const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &remote_id) override |
Add lease6 extended info into by-remote-id table. | |
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. | |
virtual | ~Memfile_LeaseMgr () |
Destructor (closes file) | |
virtual bool | addLease (const Lease4Ptr &lease) override |
Adds an IPv4 lease. | |
virtual bool | addLease (const Lease6Ptr &lease) override |
Adds an IPv6 lease. | |
virtual Lease4Ptr | getLease4 (const isc::asiolink::IOAddress &addr) const override |
Returns existing IPv4 lease for specified IPv4 address. | |
virtual Lease4Collection | getLease4 (const isc::dhcp::HWAddr &hwaddr) const override |
Returns existing IPv4 leases for specified hardware address. | |
virtual Lease4Ptr | getLease4 (const HWAddr &hwaddr, SubnetID subnet_id) const override |
Returns existing IPv4 lease for specified hardware address and a subnet. | |
virtual Lease4Collection | getLease4 (const ClientId &client_id) const override |
Returns existing IPv4 lease for specified client-id. | |
virtual Lease4Ptr | getLease4 (const ClientId &clientid, SubnetID subnet_id) const override |
Returns existing IPv4 lease for specified client-id. | |
virtual Lease4Collection | getLeases4 (SubnetID subnet_id) const override |
Returns all IPv4 leases for the particular subnet identifier. | |
virtual Lease4Collection | getLeases4 (const std::string &hostname) const override |
Returns all IPv4 leases for the particular hostname. | |
virtual Lease4Collection | getLeases4 () const override |
Returns all IPv4 leases. | |
virtual Lease4Collection | getLeases4 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const override |
Returns range of IPv4 leases using paging. | |
virtual Lease6Ptr | getLease6 (Lease::Type type, const isc::asiolink::IOAddress &addr) const override |
Returns existing IPv6 lease for a given IPv6 address. | |
virtual Lease6Collection | getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid) const override |
Returns existing IPv6 lease for a given DUID + IA + lease type combination. | |
virtual Lease6Collection | getLeases6 (Lease::Type type, const DUID &duid, uint32_t iaid, SubnetID subnet_id) const override |
Returns existing IPv6 lease for a given DUID + IA + subnet-id + lease type combination. | |
virtual Lease6Collection | getLeases6 (SubnetID subnet_id) const override |
Returns all IPv6 leases for the particular subnet identifier. | |
virtual Lease6Collection | getLeases6 (const std::string &hostname) const override |
Returns all IPv6 leases for the particular hostname. | |
virtual Lease6Collection | getLeases6 () const override |
Returns all IPv6 leases. | |
virtual Lease6Collection | getLeases6 (const DUID &duid) const override |
Returns IPv6 leases for the DUID. | |
virtual Lease6Collection | getLeases6 (const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const override |
Returns range of IPv6 leases using paging. | |
virtual Lease6Collection | getLeases6 (SubnetID subnet_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size) const override |
Returns a page of IPv6 leases for a subnet identifier. | |
virtual void | getExpiredLeases4 (Lease4Collection &expired_leases, const size_t max_leases) const override |
Returns a collection of expired DHCPv4 leases. | |
virtual void | getExpiredLeases6 (Lease6Collection &expired_leases, const size_t max_leases) const override |
Returns a collection of expired DHCPv6 leases. | |
virtual void | updateLease4 (const Lease4Ptr &lease4) override |
Updates IPv4 lease. | |
virtual void | updateLease6 (const Lease6Ptr &lease6) override |
Updates IPv6 lease. | |
virtual bool | deleteLease (const Lease4Ptr &lease) override |
Deletes an IPv4 lease. | |
virtual bool | deleteLease (const Lease6Ptr &lease) override |
Deletes an IPv6 lease. | |
virtual uint64_t | deleteExpiredReclaimedLeases4 (const uint32_t secs) override |
Deletes all expired-reclaimed DHCPv4 leases. | |
virtual uint64_t | deleteExpiredReclaimedLeases6 (const uint32_t secs) override |
Deletes all expired-reclaimed DHCPv6 leases. | |
virtual size_t | wipeLeases4 (const SubnetID &subnet_id) override |
Removes specified IPv4 leases. | |
virtual size_t | wipeLeases6 (const SubnetID &subnet_id) override |
Removed specified IPv6 leases. | |
virtual std::string | checkLimits4 (isc::data::ConstElementPtr const &user_context) const override |
Checks if the IPv4 lease limits set in the given user context are exceeded. | |
virtual std::string | checkLimits6 (isc::data::ConstElementPtr const &user_context) const override |
Checks if the IPv6 lease limits set in the given user context are exceeded. | |
virtual bool | isJsonSupported () const override |
Checks if JSON support is enabled in the database. | |
static std::string | getDBVersion () |
Return extended version info. | |
static std::string | getDBVersionInternal (Universe const &u) |
Local version of getDBVersion() class method. | |
Additional Inherited Members | |
Static Public Member Functions inherited from isc::dhcp::LeaseMgr | |
static void | extractLease4ExtendedInfo (const Lease4Ptr &lease, bool ignore_errors=true) |
Extract relay and remote identifiers from the extended info. | |
static std::string | getDBVersion () |
Class method to return extended version info This class method must be redeclared and redefined in derived classes. | |
static bool | upgradeLease4ExtendedInfo (const Lease4Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX) |
The following queries are used to fulfill Bulk Lease Query queries. | |
static bool | upgradeLease6ExtendedInfo (const Lease6Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX) |
Upgrade a V6 lease user context to the new extended info entry. | |
Protected Types inherited from isc::dhcp::TrackingLeaseMgr | |
typedef boost::multi_index_container< Callback, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, CallbackType, &Callback::type >, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > >, boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > > > > | CallbackContainer |
A multi-index container holding registered callbacks. | |
typedef boost::shared_ptr< CallbackContainer > | CallbackContainerPtr |
Pointer to the callback container. | |
Static Protected Member Functions inherited from isc::dhcp::TrackingLeaseMgr | |
static std::string | callbackTypeToString (CallbackType type) |
Converts callback type to string for logging purposes. | |
Protected Attributes inherited from isc::dhcp::TrackingLeaseMgr | |
CallbackContainerPtr | callbacks_ |
The multi-index container holding registered callbacks. | |
std::unordered_set< asiolink::IOAddress, asiolink::IOAddress::Hash > | locked_leases_ |
A set of locked leases. | |
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 81 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 956 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 124 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 976 of file memfile_lease_mgr.cc.
References buildExtendedInfoTables6(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES, isc::dhcp::DHCPSRV_MEMFILE_NO_STORAGE, extractExtendedInfo4(), isc::db::DatabaseConnection::getParameter(), getVersion(), lease_file4_, lease_file6_, LOG_WARN, persistLeases(), isc::dhcp::LeaseMgr::setExtendedInfoTablesEnabled(), V4, V6, and version().
Referenced by factory().
|
virtual |
Destructor (closes file)
Definition at line 1021 of file memfile_lease_mgr.cc.
References lease_file4_, and lease_file6_.
|
overridevirtual |
Adds an IPv4 lease.
lease | lease to be added |
Implements isc::dhcp::LeaseMgr.
Definition at line 1086 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
Adds an IPv6 lease.
lease | lease to be added |
Implements isc::dhcp::LeaseMgr.
Definition at line 1135 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_ADD_ADDR6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overrideprotectedvirtual |
Add lease6 extended info into by-relay-id table.
lease_addr | The address of the lease. |
relay_id | The relay id from the relay header options. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3373 of file memfile_lease_mgr.cc.
References relay_id6_.
|
overrideprotectedvirtual |
Add lease6 extended info into by-remote-id table.
lease_addr | The address of the lease. |
remote_id | The remote id from the relay header options. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3381 of file memfile_lease_mgr.cc.
References remote_id6_.
|
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 2206 of file memfile_lease_mgr.cc.
References FILE_FINISH, FILE_INPUT, FILE_OUTPUT, FILE_PID, and FILE_PREVIOUS.
Referenced by isc::dhcp::LFCSetup::setup().
|
protected |
Extended information / Bulk Lease Query shared interface.
Build extended info v6 tables.
Definition at line 3311 of file memfile_lease_mgr.cc.
References isc::dhcp::LeaseMgr::addExtendedInfo6(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_BEGIN_BUILD_EXTENDED_INFO_TABLES6, isc::dhcp::DHCPSRV_MEMFILE_BUILD_EXTENDED_INFO_TABLES6, isc::dhcp::DHCPSRV_MEMFILE_BUILD_EXTENDED_INFO_TABLES6_ERROR, isc::dhcp::LeaseMgr::getExtendedInfoTablesEnabled(), isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, LOG_DEBUG, LOG_ERROR, LOG_INFO, relay_id6_, remote_id6_, isc::dhcp::CfgConsistency::sanityCheckToText(), and isc::dhcp::LeaseMgr::upgradeLease6ExtendedInfo().
Referenced by Memfile_LeaseMgr().
|
overridevirtual |
Return the by-relay-id table size.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 3111 of file memfile_lease_mgr.cc.
References relay_id6_.
|
overridevirtual |
Return the by-remote-id table size.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 3116 of file memfile_lease_mgr.cc.
References remote_id6_.
|
overridevirtual |
Checks if the IPv4 lease limits set in the given user context are exceeded.
Memfile implementation.
user_context | all or part of the lease's user context which, for the intents and purposes of lease limiting should have the following format (not all nodes are mandatory and values are given only as examples): { "ISC": { "limits": { "client-classes": [ { "name": "foo", "address-limit": 2 } ], "subnet": { "id": 1, "address-limit": 2 } } } } |
Implements isc::dhcp::LeaseMgr.
Definition at line 2685 of file memfile_lease_mgr.cc.
References getClassLeaseCount(), isc_throw, isc::data::prettyPrint(), and isc::dhcp::Lease::TYPE_V4.
|
overridevirtual |
Checks if the IPv6 lease limits set in the given user context are exceeded.
Memfile implementation.
user_context | all or part of the lease's user context which, for the intents and purposes of lease limiting should have the following format (not all nodes are mandatory and values are given only as examples): { "ISC": { "limits": { "client-classes": [ { "name": "foo", "address-limit": 2, "prefix-limit": 1 } ], "subnet": { "id": 1, "address-limit": 2, "prefix-limit": 1 } } } } |
Implements isc::dhcp::LeaseMgr.
Definition at line 2771 of file memfile_lease_mgr.cc.
References getClassLeaseCount(), isc_throw, isc::data::prettyPrint(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.
|
overridevirtual |
Clears the class-lease count map.
Must be called from a thread-safe context.
Implements isc::dhcp::LeaseMgr.
Definition at line 2680 of file memfile_lease_mgr.cc.
References isc::dhcp::ClassLeaseCounter::clear().
|
overridevirtual |
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 2195 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.
|
overridevirtual |
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 2080 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED4, isc::util::MultiThreadingMgr::instance(), lease_file4_, LOG_DEBUG, and V4.
|
overridevirtual |
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 2098 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_EXPIRED_RECLAIMED6, isc::util::MultiThreadingMgr::instance(), lease_file6_, LOG_DEBUG, and V6.
|
overrideprotectedvirtual |
Delete lease6 extended info from tables.
addr | The address of the lease. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3363 of file memfile_lease_mgr.cc.
References relay_id6_, and remote_id6_.
|
overridevirtual |
Deletes an IPv4 lease.
lease | IPv4 lease being deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 2008 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
Referenced by wipeLeases4(), and wipeLeases6().
|
overridevirtual |
Deletes an IPv6 lease.
lease | IPv6 lease being deleted. |
Implements isc::dhcp::LeaseMgr.
Definition at line 2067 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DELETE_ADDR6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
size_t isc::dhcp::Memfile_LeaseMgr::extractExtendedInfo4 | ( | bool | update, |
bool | current ) |
Extract extended info for v4 leases.
For v4 relay and remote identifiers are stored inside leases vs. tables for v6.
update | Update extended info in database. |
current | specify whether to use current (true) or staging (false) config. |
Definition at line 3242 of file memfile_lease_mgr.cc.
References isc::data::copy(), isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_BEGIN_EXTRACT_EXTENDED_INFO4, isc::dhcp::DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4, isc::dhcp::DHCPSRV_MEMFILE_EXTRACT_EXTENDED_INFO4_ERROR, isc::dhcp::LeaseMgr::extractLease4ExtendedInfo(), isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, lease_file4_, LOG_DEBUG, LOG_INFO, persistLeases(), isc::dhcp::CfgConsistency::sanityCheckToText(), isc::dhcp::LeaseMgr::upgradeLease4ExtendedInfo(), and V4.
Referenced by Memfile_LeaseMgr().
|
static |
Factory class method.
parameters | A data structure relating keywords and values concerned with the database. |
Definition at line 3463 of file memfile_lease_mgr.cc.
References Memfile_LeaseMgr(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DB, LOG_INFO, and isc::db::DatabaseConnection::redactedAccessString().
Referenced by isc::dhcp::MemfileLeaseMgrInit::MemfileLeaseMgrInit().
|
overridevirtual |
Returns the class lease count for a given class and lease type.
client_class | client class for which the count is desired |
ltype | type of lease for which the count is desired. Defaults to Lease::TYPE_V4. |
Implements isc::dhcp::LeaseMgr.
Definition at line 2669 of file memfile_lease_mgr.cc.
References isc::dhcp::ClassLeaseCounter::getClassCount(), and isc::util::MultiThreadingMgr::instance().
Referenced by checkLimits4(), and checkLimits6().
|
static |
Return extended version info.
Definition at line 1045 of file memfile_lease_mgr.cc.
References getDBVersionInternal(), isc::dhcp::CfgMgr::getFamily(), isc::dhcp::CfgMgr::instance(), V4, and V6.
Referenced by isc::dhcp::MemfileLeaseMgrInit::MemfileLeaseMgrInit().
|
static |
Local version of getDBVersion() class method.
Definition at line 1033 of file memfile_lease_mgr.cc.
References MAJOR_VERSION_V4, MAJOR_VERSION_V6, MINOR_VERSION_V4, MINOR_VERSION_V6, V4, and V6.
Referenced by getDBVersion().
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 2234 of file memfile_lease_mgr.cc.
References isc::dhcp::CfgMgr::getDataDir(), isc::dhcp::CfgMgr::instance(), and V4.
|
overridevirtual |
Returns description of the backend.
This description may be multiline text that describes the backend.
Implements isc::dhcp::LeaseMgr.
Definition at line 2179 of file memfile_lease_mgr.cc.
|
overridevirtual |
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 1780 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
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 1816 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_EXPIRED6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
Returns existing IPv4 lease for specified client-id.
client_id | client identifier |
Implements isc::dhcp::LeaseMgr.
Definition at line 1253 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_CLIENTID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().
|
overridevirtual |
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 1286 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_CLIENTID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().
|
overridevirtual |
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 1222 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_HWADDR, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::HWAddr::toText().
|
overridevirtual |
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 1159 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR4, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
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 1188 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HWADDR, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::HWAddr::toText().
|
overridevirtual |
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 1447 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_ADDR6, isc::util::MultiThreadingMgr::instance(), 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 2243 of file memfile_lease_mgr.cc.
References lease_file4_, lease_file6_, and V4.
|
overridevirtual |
Returns all IPv4 leases.
Implements isc::dhcp::LeaseMgr.
Definition at line 1366 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
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 1401 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE4, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
Returns all IPv4 leases for the particular hostname.
hostname | hostname in lower case. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1343 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
Returns all IPv4 leases for the particular subnet identifier.
subnet_id | subnet identifier. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1314 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
The following queries are used to fulfill Bulk Lease Query queries.
They rely on relay data contained in lease's user-context when the extended-store-info flag is enabled.
Returns existing IPv4 leases with a given relay-id.
relay_id | RAI Relay-ID sub-option value for relay_id of interest |
lower_bound_address | IPv4 address used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
qry_start_time | when not zero, only leases whose CLTT is greater than or equal to this value will be included |
qry_end_time | when not zero, only leases whose CLTT is less than or equal to this value will be included |
Implements isc::dhcp::LeaseMgr.
Definition at line 2927 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_RELAYID4, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
Returns existing IPv4 leases with a given remote-id.
remote_id | RAI Remote-ID sub-option value for remote-id of interest |
lower_bound_address | IPv4 address used as lower bound for the returned range. |
page_size | maximum size of the page returned. |
qry_start_time | when not zero, only leases whose CLTT is greater than or equal to this value will be included. Defaults to zero. |
qry_end_time | when not zero, only leases whose CLTT is less than or equal to this value will be included. Defaults to zero. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3013 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_REMOTEID4, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV4(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
Returns all IPv6 leases.
Implements isc::dhcp::LeaseMgr.
Definition at line 1612 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
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 1676 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_PAGE6, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
Returns IPv6 leases for the DUID.
duid | client DUID |
Implements isc::dhcp::LeaseMgr.
Definition at line 1640 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET6_DUID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, and isc::dhcp::IdentifierType< min_size, max_size >::toText().
|
overridevirtual |
Returns all IPv6 leases for the particular hostname.
hostname | hostname in lower case. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1589 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_HOSTNAME6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
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 1481 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_IAID_DUID, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::dhcp::IdentifierType< min_size, max_size >::toText(), and isc::dhcp::Lease::typeToText().
|
overridevirtual |
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 1524 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, isc::util::MultiThreadingMgr::instance(), LOG_DEBUG, isc::dhcp::IdentifierType< min_size, max_size >::toText(), and isc::dhcp::Lease::typeToText().
|
overridevirtual |
Returns all IPv6 leases for the particular subnet identifier.
subnet_id | subnet identifier. |
Implements isc::dhcp::LeaseMgr.
Definition at line 1560 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
Returns a page of IPv6 leases for a subnet identifier.
subnet_id | subnet identifier. |
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 1729 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_SUBID_PAGE6, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, and isc::asiolink::IOAddress::toText().
|
overridevirtual |
Returns existing IPv6 leases with a given relay-id.
relay_id | DUID for relay_id of interest. |
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 3121 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_RELAYID6, isc::util::MultiThreadingMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV6(), LOG_DEBUG, isc::dhcp::LeasePageSize::page_size_, isc::asiolink::IOAddress::toText(), and isc::dhcp::IdentifierType< min_size, max_size >::toText().
|
overridevirtual |
Returns existing IPv6 leases with a given remote-id.
remote_id | remote-id option data of interest |
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 3183 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_GET_REMOTEID6, isc::util::MultiThreadingMgr::instance(), 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 2378 of file memfile_lease_mgr.cc.
|
inlineoverridevirtual |
Returns backend name.
For now, memfile can only store data in memory.
Implements isc::dhcp::LeaseMgr.
Definition at line 917 of file memfile_lease_mgr.h.
|
inlineoverridevirtual |
Return backend type.
Returns the type of the backend.
Implements isc::dhcp::LeaseMgr.
Definition at line 908 of file memfile_lease_mgr.h.
|
overridevirtual |
Returns backend version.
timer_name | The DB reconnect timer name. |
Implements isc::dhcp::LeaseMgr.
Definition at line 2184 of file memfile_lease_mgr.cc.
References isc::db::DatabaseConnection::getParameter(), isc_throw, MAJOR_VERSION_V4, MAJOR_VERSION_V6, MINOR_VERSION_V4, and MINOR_VERSION_V6.
Referenced by Memfile_LeaseMgr().
|
overridevirtual |
Checks if JSON support is enabled in the database.
Memfile implementation assumes JSON support is always enabled.
Implements isc::dhcp::LeaseMgr.
Definition at line 2872 of file memfile_lease_mgr.cc.
bool isc::dhcp::Memfile_LeaseMgr::isLFCRunning | ( | ) | const |
Checks if the process performing lease file cleanup is running.
Definition at line 2373 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 2383 of file memfile_lease_mgr.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_LFC_START, lease_file4_, lease_file6_, 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 2252 of file memfile_lease_mgr.cc.
References lease_file4_, lease_file6_, V4, and V6.
Referenced by Memfile_LeaseMgr(), and extractExtendedInfo4().
|
overridevirtual |
Recount the leases per class for V4 leases.
Clears the current class-lease count map and then iterates over all, retabulating counts based on class lists in each lease user-context.
Must be called from a thread-safe context.
Implements isc::dhcp::LeaseMgr.
Definition at line 2647 of file memfile_lease_mgr.cc.
References isc::dhcp::ClassLeaseCounter::addLease(), isc::dhcp::ClassLeaseCounter::clear(), and isc::dhcp::Lease::STATE_DEFAULT.
|
overridevirtual |
Recount the leases per class for V6 leases.
Clears the current class-lease count map and then iterates over all, retabulating counts based on class lists in each lease user-context.
Must be called from a thread-safe context.
Implements isc::dhcp::LeaseMgr.
Definition at line 2658 of file memfile_lease_mgr.cc.
References isc::dhcp::ClassLeaseCounter::addLease(), isc::dhcp::ClassLeaseCounter::clear(), and isc::dhcp::Lease::STATE_DEFAULT.
|
overridevirtual |
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 2200 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.
|
overridevirtual |
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 2481 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 2535 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
Creates and runs the IPv4 lease stats query for all subnets and pools.
LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv4 lease statistical data for all subnets and pools. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID and pool ID.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 2494 of file memfile_lease_mgr.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, and isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
Creates and runs the IPv6 lease stats query for all subnets and pools.
LeaseMgr derivations implement this method such that it creates and returns an instance of an LeaseStatsQuery whose result set has been populated with up to date IPv6 lease statistical data for all subnets and pools. Each row of the result set is an LeaseStatRow which ordered ascending by subnet ID and pool ID.
Reimplemented from isc::dhcp::LeaseMgr.
Definition at line 2548 of file memfile_lease_mgr.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, and isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 2507 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 2561 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 2520 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 2574 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
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 1876 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR4, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
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 1956 of file memfile_lease_mgr.cc.
References isc::dhcp::DHCPSRV_DBG_TRACE_DETAIL, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_UPDATE_ADDR6, isc::util::MultiThreadingMgr::instance(), and LOG_DEBUG.
|
overridevirtual |
Upgrade extended info (v4).
page_size | The page size used for retrieval. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3306 of file memfile_lease_mgr.cc.
|
overridevirtual |
Upgrade extended info (v6).
page_size | The page size used for retrieval. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3358 of file memfile_lease_mgr.cc.
|
overridevirtual |
Wipe extended info table (v6).
Implements isc::dhcp::LeaseMgr.
Definition at line 3099 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance(), relay_id6_, and remote_id6_.
|
overridevirtual |
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 2589 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.
|
overridevirtual |
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 2618 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.
|
overridevirtual |
Write V4 leases to a file.
filename | File name to write leases. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3389 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
overridevirtual |
Write V6 leases to a file.
filename | File name to write leases. |
Implements isc::dhcp::LeaseMgr.
Definition at line 3426 of file memfile_lease_mgr.cc.
References isc::util::MultiThreadingMgr::instance().
|
protected |
Holds the pointer to the DHCPv4 lease file IO.
Definition at line 1115 of file memfile_lease_mgr.h.
Referenced by Memfile_LeaseMgr(), ~Memfile_LeaseMgr(), deleteExpiredReclaimedLeases4(), extractExtendedInfo4(), getLeaseFilePath(), lfcCallback(), and persistLeases().
|
protected |
Holds the pointer to the DHCPv6 lease file IO.
Definition at line 1118 of file memfile_lease_mgr.h.
Referenced by Memfile_LeaseMgr(), ~Memfile_LeaseMgr(), deleteExpiredReclaimedLeases6(), getLeaseFilePath(), lfcCallback(), and persistLeases().
|
protected |
stores IPv6 by-relay-id cross-reference table
Definition at line 1109 of file memfile_lease_mgr.h.
Referenced by addRelayId6(), buildExtendedInfoTables6(), byRelayId6size(), deleteExtendedInfo6(), and wipeExtendedInfoTables6().
|
protected |
stores IPv6 by-remote-id cross-reference table
Definition at line 1112 of file memfile_lease_mgr.h.
Referenced by addRemoteId6(), buildExtendedInfoTables6(), byRemoteId6size(), deleteExtendedInfo6(), and wipeExtendedInfoTables6().