From: Daniel Salzman Date: Wed, 8 Oct 2025 16:06:00 +0000 (+0200) Subject: zonedb-load: fix zone loading which were included by conf-set include X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bb86cbe19082f4af6b70c343b565c71f272c222;p=thirdparty%2Fknot-dns.git zonedb-load: fix zone loading which were included by conf-set include --- diff --git a/src/knot/zone/zonedb-load.c b/src/knot/zone/zonedb-load.c index e27737b1ab..f7135b0df3 100644 --- a/src/knot/zone/zonedb-load.c +++ b/src/knot/zone/zonedb-load.c @@ -483,6 +483,26 @@ static knot_zonedb_t *create_zonedb_commit(conf_t *conf, server_t *server) return NULL; } + assert(conf->io.flags & CONF_IO_FACTIVE); + bool include = conf->io.flags & CONF_IO_FDIFF_ZONES; + + // Insert possibly added zones by conf-set include. + if (include) { + for (conf_iter_t it = conf_iter(conf, C_ZONE); it.code == KNOT_EOK; + conf_iter_next(conf, &it)) { + conf_val_t id = conf_iter_id(conf, &it); + const knot_dname_t *name = conf_dname(&id); + zone_t *zone = knot_zonedb_find(db_new, name); + if (zone == NULL) { // Create an included zone. + zone = get_zone(conf, name, server, NULL); + if (zone == NULL) { + continue; + } + knot_zonedb_insert(db_new, zone); + } + } + } + if (conf->io.zones != NULL) { trie_it_t *trie_it = trie_it_begin(conf->io.zones); for (; !trie_it_finished(trie_it); trie_it_next(trie_it)) { diff --git a/tests-extra/tests/config/include/test.py b/tests-extra/tests/config/include/test.py index 113e61e675..a448faab9a 100644 --- a/tests-extra/tests/config/include/test.py +++ b/tests-extra/tests/config/include/test.py @@ -30,6 +30,12 @@ ctl = libknot.control.KnotCtl() t.start() +knot.use_confdb = True +knot.gen_confile() +knot.ctl("conf-import %s" % knot.confile, availability=False) +knot.stop() +knot.start() + ctl.connect(os.path.join(knot.dir, "knot.sock")) ctl.send_block(cmd="conf-begin") @@ -37,9 +43,11 @@ resp = ctl.receive_block() ctl.send_block(cmd="conf-set", section="include", data=added_file) resp = ctl.receive_block() -# Cannot commit as it reloads the server without this include! -ctl.send_block(cmd="conf-get", section="zone") +ctl.send_block(cmd="conf-commit") +resp = ctl.receive_block() + +ctl.send_block(cmd="conf-read", section="zone") resp = ctl.receive_block() isset(ZONE1 in resp['zone'], ZONE1) @@ -47,15 +55,20 @@ isset(ZONE2 in resp['zone'], ZONE2) isset(ZONE3 in resp['zone'], ZONE3) isset(ZONE4 in resp['zone'], ZONE4) -ctl.send_block(cmd="conf-commit") -resp = ctl.receive_block() - ctl.send_block(cmd="conf-read", section="server") resp = ctl.receive_block() isset('tcp-max-clients' in resp['server'], "server section item not set") isset('5' in resp['server']['tcp-max-clients'], "server section item value not set") +ctl.send_block(cmd="zone-status") +resp = ctl.receive_block() + +isset(ZONE1 in resp, ZONE1) +isset(ZONE2 in resp, ZONE2) +isset(ZONE3 in resp, ZONE3) +isset(ZONE4 in resp, ZONE4) + ctl.send(libknot.control.KnotCtlType.END) ctl.close() diff --git a/tests-extra/tools/dnstest/server.py b/tests-extra/tools/dnstest/server.py index 88b890145f..22fa8a1545 100644 --- a/tests-extra/tools/dnstest/server.py +++ b/tests-extra/tools/dnstest/server.py @@ -158,6 +158,7 @@ class Server(object): self.start_params = None self.ctl_params = None self.ctl_params_append = None # The last parameter wins. + self.use_confdb = False self.data_dir = None @@ -2048,8 +2049,12 @@ class Knot(Server): s.item_str("quic", "debug") s.end() - self.start_params = ["-c", self.confile] - self.ctl_params = ["-c", self.confile, "-t", "15"] + if self.use_confdb: + conf_params = ["-C", os.path.join(self.dir, "confdb")] + else: + conf_params = ["-c", self.confile] + self.start_params = conf_params + self.ctl_params = conf_params + ["-t", "15"] if self.ctl_params_append != None: self.ctl_params += self.ctl_params_append