bind-dyndb-ldap version 11 is doing run-time synchronization of resource records, zones, and configuration between BIND and LDAP server. Some of the changes done by the plugin are not directly supported by BIND interfaces used so care needs to be taken to ensure proper locking and synchronization of events inside BIND.
To understand this area it is necessary to understand SyncRepl protocol, BIND internals, and the locking layer the plugin adds on top of all this.
SyncRepl protocol itself supports two different modes:
refreshOnly and
refreshAndPersist.
The refreshAndPersist
mode is further divided to refresh
and
persist
stages:
Because of interdependence between LDAP entries representing DNS data, the plugin needs to load configuration and all the data first. DNS zone loading is done only after initial synchronization is finished.
The plugin internally tracks state of synchronization in
struct sync_ctx
, which uses enum sync_state
to as
synchronization state machine.
The plugin version 11 is using refreshOnly
mode for configuration
synchronization during startup. When configuration is synchronized, the
plugin uses refreshAndPersist
mode to pull all data from LDAP and to
keep them synchronized on the fly.
ldap_syncrepl_watcher()
thread works like this:
configinit
:refreshOnly
mode to read
configuration objectsidnsConfigObject
and idnsServerConfigObject
)ldap_sync_search_entry()
and transform the
entry to an BIND event.ldap_syncrepl_watcher()
thread.struct sync_ctx
.ldap_sync_search_result()
and enter state configbarrier
:LDAPDB_EVENT_SYNCREPL_BARRIER
event to each task which
participates in event processing from the previous step.LDAPDB_EVENT_SYNCREPL_BARRIER
events are
processed.datainit
:refreshAndPersisnt
mode to read
all DNS objects from LDAPconfiginit
.dns_zone_load()
): the zone data are
not yet completely available so zone loading would fail anywayrefresh
stage were received, execute
callback ldap_sync_intermediate()
and enter state
databarrier
:LDAPDB_EVENT_SYNCREPL_BARRIER
event to each task which
participates in event processing from the previous step. Same as in
step configbarrier
.finished
:persist
stage of SyncRepl
session. The plugin receives change notification about each modified
LADP entry. The DNS journal is updated for each modification and SOA
serial is incremented.Real implementation of synchronization machinery in the plugin needs to store metadata about LDAP entries. In certain cases the SyncRepl protocol can use LDAP entry UUID RFC4530 instead of sending full LDAP entry or its DN. In such cases the plugin has to map LDAP entry UUID to an internal object which needs to be modified (e.g. deleted). See Design/MetaDB for full metaLDAP design.
In plugin version 11, the SyncRepl callback
ldap_sync_search_entry()
is responsible for keeping internal
metadata database. It keeps mapping from LDAP entry UUID to:
When entering datainit
state, the plugin increments the generation
ID (this includes reconnections to LDAP from the same plugin instance).
For all LDAP entries processed by the plugin, the generation ID is
stored in the metaLDAP database.
At the end of refresh
stage, the ldap_sync_intermediate()
callback walks through all entries in metaLDAP and triggers object
removal for all entries which do have generation ID smaller than current
generation ID. Such objects were loaded sometime in the past but are not
present in LDAP anymore.