diff --git a/CHANGES b/CHANGES index 1c33528f4c..739fbafc55 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +6115. [bug] Unregister db update notify callback before detaching + from the previous db inside the catz update notify + callback. Also, call the db notify callbacks only after + zone_postload() returns successfully. [GL #3777] + 6114. [func] Run the catalog zone update process on the offload threads. [GL #3881] diff --git a/bin/tests/system/catz/clean.sh b/bin/tests/system/catz/clean.sh index 40a348aa0b..21dbc752c1 100644 --- a/bin/tests/system/catz/clean.sh +++ b/bin/tests/system/catz/clean.sh @@ -29,6 +29,7 @@ rm -f ns2/catalog-bad*.db rm -f ns2/named.conf.tmp rm -f ns3/dom2.example.db ns3/dom13.example.db ns3/dom14.example.db ns3/dom17.example.db ns3/dom18.example.db rm -f ns4/__catz__*db +rm -f ns4/catalog-self.example.db rm -f ns[123]/catalog[1234].example.db rm -f ns[14]/catalog-tls.example.db rm -f nsupdate.out.* diff --git a/bin/tests/system/catz/ns4/catalog.example.db.in b/bin/tests/system/catz/ns4/catalog.example.db.in new file mode 100644 index 0000000000..a0bab0dfe2 --- /dev/null +++ b/bin/tests/system/catz/ns4/catalog.example.db.in @@ -0,0 +1,14 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; SPDX-License-Identifier: MPL-2.0 +; +; 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. + +@ 3600 SOA . . 1 86400 3600 86400 3600 +@ 3600 IN NS invalid. +version IN TXT "1" diff --git a/bin/tests/system/catz/ns4/named.conf.in b/bin/tests/system/catz/ns4/named.conf.in index 2256836584..73a2bb7b49 100644 --- a/bin/tests/system/catz/ns4/named.conf.in +++ b/bin/tests/system/catz/ns4/named.conf.in @@ -30,11 +30,15 @@ options { notify-delay 0; recursion no; serial-query-rate 100; + ixfr-from-differences yes; // GL #3777 catalog-zones { zone "catalog-tls.example" min-update-interval 1s default-primaries { 10.53.0.1 key tsig_key tls ephemeral; }; + zone "catalog-self.example" + min-update-interval 1s + default-primaries { 10.53.0.4; }; }; }; @@ -44,6 +48,12 @@ zone "catalog-tls.example" { primaries { 10.53.0.1 key tsig_key tls ephemeral; }; }; +zone "catalog-self.example" { + type primary; + file "catalog-self.example.db"; + notify explicit; +}; + key tsig_key. { secret "LSAnCU+Z"; algorithm @DEFAULT_HMAC@; diff --git a/bin/tests/system/catz/setup.sh b/bin/tests/system/catz/setup.sh index ce1f931b18..eb2e53bd1a 100644 --- a/bin/tests/system/catz/setup.sh +++ b/bin/tests/system/catz/setup.sh @@ -25,5 +25,6 @@ cp -f ns3/catalog.example.db.in ns3/catalog2.example.db cp -f ns1/catalog.example.db.in ns1/catalog3.example.db cp -f ns1/catalog.example.db.in ns1/catalog4.example.db cp -f ns1/catalog.example.db.in ns1/catalog-tls.example.db +cp -f ns4/catalog.example.db.in ns4/catalog-self.example.db mkdir -p ns2/zonedir diff --git a/bin/tests/system/catz/tests.sh b/bin/tests/system/catz/tests.sh index 9cb167b31d..a0ed0533be 100644 --- a/bin/tests/system/catz/tests.sh +++ b/bin/tests/system/catz/tests.sh @@ -2605,5 +2605,23 @@ wait_for_soa @10.53.0.4 tls1.example. dig.out.test$n || ret=1 if [ $ret -ne 0 ]; then echo_i "failed"; fi status=$((status+ret)) +########################################################################## +# GL #3777 +nextpart ns4/named.run >/dev/null + +n=$((n+1)) +echo_i "Adding domain self.example. to catalog-self zone without updating the serial ($n)" +ret=0 +echo "self.zones.catalog-self.example. 3600 IN PTR self.example." >> ns4/catalog-self.example.db +rndccmd 10.53.0.4 reload || ret=1 + +n=$((n+1)) +echo_i "Issuing another rndc reload command after 1 second ($n)" +sleep 1 +rndccmd 10.53.0.4 reload || ret=1 +if [ $ret -ne 0 ]; then echo_i "failed"; fi +status=$((status+ret)) + +########################################################################## echo_i "exit status: $status" [ $status -eq 0 ] || exit 1 diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 7e28528f57..2faef31132 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -910,8 +910,10 @@ dns_catz_get_zone(dns_catz_zones_t *catzs, const dns_name_t *name) { REQUIRE(DNS_CATZ_ZONES_VALID(catzs)); REQUIRE(ISC_MAGIC_VALID(name, DNS_NAME_MAGIC)); + LOCK(&catzs->lock); result = isc_ht_find(catzs->zones, name->ndata, name->length, (void **)&found); + UNLOCK(&catzs->lock); if (result != ISC_R_SUCCESS) { return (NULL); } @@ -2104,6 +2106,8 @@ dns_catz_dbupdate_callback(dns_db_t *db, void *fn_arg) { if (catz->dbversion != NULL) { dns_db_closeversion(catz->db, &catz->dbversion, false); } + dns_db_updatenotify_unregister( + catz->db, dns_catz_dbupdate_callback, catz->catzs); dns_db_detach(&catz->db); /* * We're not registering db update callback, it will be diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 3668c4c437..4e2d746718 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -17225,13 +17225,6 @@ zone_loaddone(void *arg, isc_result_t result) { dns_zone_catz_disable_db(zone, load->db); } - tresult = dns_db_endload(load->db, &load->callbacks); - if (tresult != ISC_R_SUCCESS && - (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE)) - { - result = tresult; - } - /* * Lock hierarchy: zmgr, zone, raw. */ @@ -17250,9 +17243,13 @@ again: goto again; } } - (void)zone_postload(zone, load->db, load->loadtime, result); + tresult = zone_postload(zone, load->db, load->loadtime, result); + if (tresult != ISC_R_SUCCESS && + (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE)) + { + result = tresult; + } DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADING); - zone_idetach(&load->callbacks.zone); /* * Leave the zone frozen if the reload fails. */ @@ -17269,6 +17266,12 @@ again: } UNLOCK_ZONE(zone); + (void)dns_db_endload(load->db, &load->callbacks); + + LOCK_ZONE(zone); + zone_idetach(&load->callbacks.zone); + UNLOCK_ZONE(zone); + dns_db_detach(&load->db); if (zone->loadctx != NULL) { dns_loadctx_detach(&zone->loadctx);