]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Dump delegation database in 'rndc dumpdb'
authorColin Vidal <colin@isc.org>
Mon, 30 Mar 2026 09:22:32 +0000 (11:22 +0200)
committerColin Vidal <colin@isc.org>
Mon, 30 Mar 2026 18:41:13 +0000 (20:41 +0200)
When dumping the cache, include the contents of the delegation
database. Add a new 'rndc dumpdb -deleg' option, which dumps
the delegation database exclusively.

While the delegation database dumping format mimic the zone file format,
the API does not use the `dns_master_style_t` configuration (i.e. to
specify how many spaces/tab are used between each RR fields), because
the generic API handling this relies on databse using `dns_rdataset_t`
as internal storage format. This can be improved later.

bin/named/server.c
bin/rndc/rndc.rst

index 067dc30ed3a61c108fa0677e879c51681c0aeae6..77a9edfef88a4109d7cb1d49caca8032a6133553 100644 (file)
@@ -244,6 +244,7 @@ struct dumpcontext {
        isc_mem_t *mctx;
        bool dumpcache;
        bool dumpzones;
+       bool dumpdeleg;
        bool dumpadb;
        bool dumpexpired;
        bool dumpfail;
@@ -10779,6 +10780,12 @@ resume:
                dns_db_attach(dctx->view->view->cachedb, &dctx->cache);
        }
 
+       if (dctx->dumpdeleg) {
+               fprintf(dctx->fp, ";\n; Delegation cache\n;\n");
+               dns_delegdb_dump(dctx->view->view->deleg, dctx->dumpexpired,
+                                dctx->fp);
+       }
+
        if (dctx->cache != NULL) {
                if (dctx->dumpadb) {
                        dns_adb_t *adb = NULL;
@@ -10794,6 +10801,7 @@ resume:
                }
                dns_db_detach(&dctx->cache);
        }
+
        if (dctx->dumpzones) {
                style = &dns_master_style_full;
        nextzone:
@@ -10882,6 +10890,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
                .mctx = server->mctx,
                .dumpcache = true,
                .dumpadb = true,
+               .dumpdeleg = true,
                .dumpfail = true,
                .viewlist = ISC_LIST_INITIALIZER,
        };
@@ -10910,23 +10919,33 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
                /* only dump zones, suppress caches */
                dctx->dumpadb = false;
                dctx->dumpcache = false;
+               dctx->dumpdeleg = false;
                dctx->dumpfail = false;
                dctx->dumpzones = true;
                ptr = next_token(lex, NULL);
+       } else if (ptr != NULL && strcmp(ptr, "-deleg") == 0) {
+               /* only dump deleg db, suppress other caches */
+               dctx->dumpcache = false;
+               dctx->dumpfail = false;
+               dctx->dumpadb = false;
+               ptr = next_token(lex, NULL);
        } else if (ptr != NULL && strcmp(ptr, "-adb") == 0) {
                /* only dump adb, suppress other caches */
                dctx->dumpcache = false;
+               dctx->dumpdeleg = false;
                dctx->dumpfail = false;
                ptr = next_token(lex, NULL);
        } else if (ptr != NULL && strcmp(ptr, "-bad") == 0) {
                /* only dump badcache, suppress other caches */
                dctx->dumpadb = false;
+               dctx->dumpdeleg = false;
                dctx->dumpcache = false;
                dctx->dumpfail = false;
                ptr = next_token(lex, NULL);
        } else if (ptr != NULL && strcmp(ptr, "-fail") == 0) {
                /* only dump servfail cache, suppress other caches */
                dctx->dumpadb = false;
+               dctx->dumpdeleg = false;
                dctx->dumpcache = false;
                ptr = next_token(lex, NULL);
        }
index 6b45366e23b40c839cad49557b7aa357a7c68cb1..bad12f66c6277ef30c3d78b976d35d1104111648 100644 (file)
@@ -239,12 +239,12 @@ Currently supported commands are:
    output file is moved to ".1", and so on. If ``number`` is specified, then
    the number of backup log files is limited to that number.
 
-.. option:: dumpdb [-all | -cache | -zones | -adb | -bad | -expired | -fail] [view ...]
+.. option:: dumpdb [-all | -cache | -deleg | -zones | -adb | -deleg | -bad | -expired | -fail] [view ...]
 
-   This command dumps the server's caches (default) and/or zones to the dump file for
-   the specified views. If no view is specified, all views are dumped.
-   (See the ``dump-file`` option in the BIND 9 Administrator Reference
-   Manual.)
+   This command dumps the server's caches (default) and/or zones to the
+   dump file for the specified views. If no view is specified, all views
+   are dumped.  (See the ``dump-file`` option in the BIND 9 Administrator
+   Reference Manual.)
 
 .. option:: fetchlimit [view]