]> git.ipfire.org Git - thirdparty/bind9.git/commit
Decouple database and node lifetimes by adding node-specific vtables
authorAlessio Podda <alessio@isc.org>
Thu, 5 Jun 2025 09:51:29 +0000 (11:51 +0200)
committerEvan Hunt <each@isc.org>
Thu, 7 Aug 2025 18:39:38 +0000 (11:39 -0700)
commitae6a34cbdae0afc1ad5186cd10fc75f3e5b97ed4
treef66b58651663c1fcebaf58a8b983d9cf4baaa068
parent4a8f77e483e050af725d701fcea39bb261d88552
Decouple database and node lifetimes by adding node-specific vtables

All databases in the codebase follow the same structure: a database is
an associative container from DNS names to nodes, and each node is an
associative container from RR types to RR data.

Each database implementation (qpzone, qpcache, sdlz, builtin, dyndb) has
its own corresponding node type (qpznode, qpcnode, etc). However, some
code needs to work with nodes generically regardless of their specific
type - for example, to acquire locks, manage references, or
register/unregister slabs from the heap.

Currently, these generic node operations are implemented as methods in
the database vtable, which creates problematic coupling between database
and node lifetimes. If a node outlives its parent database, the node
destructor will destroy all RR data, and each RR data destructor will
try to unregister from heaps by calling a virtual function from the
database vtable. Since the database was already freed, this causes a
crash.

This commit breaks the coupling by standardizing the layout of all
database nodes, adding a dedicated vtable for node operations, and
moving node-specific methods from the database vtable to the node
vtable.
43 files changed:
bin/dnssec/dnssec-cds.c
bin/dnssec/dnssec-dsfromkey.c
bin/dnssec/dnssec-importkey.c
bin/dnssec/dnssec-signzone.c
bin/named/builtin.c
bin/named/server.c
bin/named/zoneconf.c
bin/tests/system/dyndb/driver/db.c
lib/dns/adb.c
lib/dns/cache.c
lib/dns/catz.c
lib/dns/client.c
lib/dns/db.c
lib/dns/diff.c
lib/dns/include/dns/db.h
lib/dns/include/dns/rdataslab.h
lib/dns/include/dns/types.h
lib/dns/journal.c
lib/dns/masterdump.c
lib/dns/nsec.c
lib/dns/nsec3.c
lib/dns/nta.c
lib/dns/private.c
lib/dns/qpcache.c
lib/dns/qpzone.c
lib/dns/rdataslab.c
lib/dns/resolver.c
lib/dns/rootns.c
lib/dns/rpz.c
lib/dns/rriterator.c
lib/dns/sdlz.c
lib/dns/update.c
lib/dns/validator.c
lib/dns/view.c
lib/dns/zone.c
lib/dns/zoneverify.c
lib/ns/query.c
lib/ns/update.c
tests/dns/db_test.c
tests/dns/dbiterator_test.c
tests/dns/dbversion_test.c
tests/dns/qpdb_test.c
tests/dns/qpzone_test.c