From: Colin Vidal Date: Mon, 30 Mar 2026 09:22:32 +0000 (+0200) Subject: Dump delegation database in 'rndc dumpdb' X-Git-Tag: v9.21.21~4^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43a9bce3c1f70a92df7b93d84cc6b1b1b9be90de;p=thirdparty%2Fbind9.git Dump delegation database in 'rndc dumpdb' 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. --- diff --git a/bin/named/server.c b/bin/named/server.c index 067dc30ed3a..77a9edfef88 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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); } diff --git a/bin/rndc/rndc.rst b/bin/rndc/rndc.rst index 6b45366e23b..bad12f66c62 100644 --- a/bin/rndc/rndc.rst +++ b/bin/rndc/rndc.rst @@ -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]