bind9/bin/tests/system/dyndb/driver
Evan Hunt 77e7eac54c enable detailed db tracing
move database attach/detach functions to db.c, instead of
requiring them to be implemented for every database type.
instead, they must implement a 'destroy' function that is
called when references go to zero.

this enables us to use ISC_REFCOUNT_IMPL for databases,
with detailed tracing enabled by setting DNS_DB_TRACE to 1.
2023-02-21 10:13:10 -08:00
..
.gitignore address linking issues 2015-09-30 12:38:07 +10:00
AUTHORS Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
db.c enable detailed db tracing 2023-02-21 10:13:10 -08:00
db.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
driver.c remove isc_bind9 variable 2023-02-09 18:00:13 +00:00
instance.c remove isc_task completely 2023-02-16 18:35:32 +01:00
instance.h switch to using isc_loopmgr_pause() instead of task exclusive 2023-02-16 17:51:55 +01:00
log.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
log.h Include the function name when reporting unexpected errors 2022-10-17 13:43:59 +01:00
Makefile.am Update netmgr, tasks, and applications to use isc_loopmgr 2022-08-26 09:09:24 +02:00
README Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
syncptr.c refactor dyndb sample driver to use loop callbacks 2023-02-16 17:16:42 +01:00
syncptr.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
util.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
zone.c remove isc_task completely 2023-02-16 18:35:32 +01:00
zone.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00

<!--
Copyright (C) Internet Systems Consortium, Inc. ("ISC")

SPDX-License-Identifier: MPL-2.0 and ISC

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0.  If a copy of the MPL was not distributed with this
file, you can obtain one at https://mozilla.org/MPL/2.0/.

See the COPYRIGHT file distributed with this work for additional
information regarding copyright ownership.

Copyright (C) Red Hat

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND AUTHORS DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-->

To use the Dynamic DB sample driver, run named and check the log.

    $ cd testing
    $ named -gc named.conf

You should be able to see something like:

zone test/IN: loaded serial 0
zone arpa/IN: loaded serial 0

This means that the sample driver created empty zones "test." and
"arpa." as defined by "arg" parameters in named.conf.

$ dig @localhost test.

should work as usual and you should be able to see the dummy zone with
NS record pointing to the zone apex and A record with 127.0.0.1:

;; ANSWER SECTION:
test.			86400	IN	A	127.0.0.1
test.			86400	IN	NS	test.
test.			86400	IN	SOA	test. test. 0 28800 7200 604800 86400

This driver creates two empty zones and allows query/transfer/update to
all IP addresses for demonstration purposes.

The driver wraps the RBT database implementation used natively by BIND,
and modifies the addrdataset() and substractrdataset() functions to do
additional work during dynamic updates.

A dynamic update modifies the target zone as usual. After that, the
driver detects whether the modified RR was of type A or AAAA, and if so,
attempts to appropriately generate or delete a matching PTR record in
one of the two zones managed by the driver.

E.g.:

$ nsupdate
> update add a.test. 300 IN A 192.0.2.1
> send

will add the A record
a.test.			300	IN	A	192.0.2.1

and also automatically generate the PTR record
1.2.0.192.in-addr.arpa.	300	IN	PTR	a.test.

AXFR and RR deletion via dynamic updates should work as usual. Deletion
of a type A or AAAA record should delete the corresponding PTR record
too.

The zone is stored only in memory, and all changes will be lost on
reload/reconfig.

Hints for code readers:
- Driver initialization starts in driver.c: dyndb_init() function.
- New database implementation is registered by calling dns_db_register()
  and passing a function pointer to it. This sample uses the function
  create_db() to initialize the database.
- Zones are created later in instance.c: load_sample_instance_zones().
- Database entry points are in structure db.c: dns_dbmethods_t
  sampledb_methods
- sampledb_methods points to an implementation of the database interface.
  See the db.c: addrdataset() implementation and look at how the RBT
  database instance is wrapped into an additional layer of logic.