Kea 2.7.0
isc::ha::LeaseSyncFilter Class Reference

Checks if a lease fetched from the other server should be synchronized into the local lease database. More...

#include <lease_sync_filter.h>

Public Member Functions

 LeaseSyncFilter (const HAServerType &server_type, const HAConfigPtr &config)
 Constructor.
 
void apply ()
 Applies filtering rules based on the current server configuration.
 
bool shouldSync (const dhcp::LeasePtr &lease) const
 Checks if the lease should be accepted or discarded.
 

Detailed Description

Checks if a lease fetched from the other server should be synchronized into the local lease database.

In a simple case when a pair of the servers has only one relationship, a server recovering from a crash fetches all leases from the partner during the database synchronization. If a server participates in more than one relationship or the server is connected to a server having more relationships a decision whether a received lease should be stored in a database has to be made based on the filtering rules implemented in this class.

Suppose there are two relationships configured for the server and each relationship runs the DHCP service for a subset of subnets. When the server is synchronizing the lease database for one of the relationships it receives all leases from its partner. Some of them belong to this relationship and some belong to the other relationship. The server must only accept the leases belonging to the former relationship and discard the remaining ones. Accepting all leases could affect lease database integrity for the second relationship.

This class implements a simple mechanism to determine whether a lease should be accepted or discarded during the synchronization. It iterates over the configured subnets and checks which of them belong to the current relationship. It next records their IDs. For each received lease it compares the subnet identifier with the recorded list. If the lease matches the list it is accepted, otherwise it is discarded by the HAService.

If none of the configured subnets contain associations with the HA relationships the class accepts all leases. It helps to simplify HA configurations with only one relationship. Such configurations typically lack subnet/HA associations in the subnet specification.

Definition at line 52 of file lease_sync_filter.h.

Constructor & Destructor Documentation

◆ LeaseSyncFilter()

isc::ha::LeaseSyncFilter::LeaseSyncFilter ( const HAServerType & server_type,
const HAConfigPtr & config )

Constructor.

Parameters
server_typespecified whether it is a DHCPv4 or DHCPv6 server.
configHA service configuration.

Definition at line 19 of file lease_sync_filter.cc.

Member Function Documentation

◆ apply()

void isc::ha::LeaseSyncFilter::apply ( )

Applies filtering rules based on the current server configuration.

This function should be called before each synchronization in case any subnets have been added or removed. It ensures that the filter is using the most up-to-date configuration.

Definition at line 24 of file lease_sync_filter.cc.

References isc::ha::DHCPv4, and isc::dhcp::CfgMgr::instance().

+ Here is the call graph for this function:

◆ shouldSync()

bool isc::ha::LeaseSyncFilter::shouldSync ( const dhcp::LeasePtr & lease) const

Checks if the lease should be accepted or discarded.

The lease is accepted when the lease subnet belongs to this relationship or when none of the subnets have explicit associations with the configured HA relationships.

Parameters
leaselease instance.
Returns
true if the lease should be accepted, false otherwise.

Definition at line 38 of file lease_sync_filter.cc.


The documentation for this class was generated from the following files: