diff --git a/CHANGES b/CHANGES index c1d0f239f2..94d319f7eb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4038. [bug] Add 'rpz' flag to node and use it to determine whether + to call dns_rpz_delete. This should prevent unbalanced + add / delete calls. [RT #36888] + 4037. [bug] also-notify was ignoring the tsig key when checking for duplicates resulting in some expected notify messages not being sent. [RT #38369] diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index 8b382b5ed6..3cd8c61d33 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -115,6 +115,9 @@ struct dns_rbtnode { unsigned int oldnamelen : 8; /*%< range is 1..255 */ /*@}*/ + /* node needs to be cleaned from rpz */ + unsigned int rpz : 1; + #ifdef DNS_RBT_USEHASH unsigned int hashval; #endif diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 0e9c5f9505..9c5ce6ee49 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -1446,6 +1446,8 @@ create_node(isc_mem_t *mctx, dns_name_t *name, dns_rbtnode_t **nodep) { LEFT(node) = NULL; DOWN(node) = NULL; DATA(node) = NULL; + node->rpz = 0; + #ifdef DNS_RBT_USEHASH HASHNEXT(node) = NULL; HASHVAL(node) = 0; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index a8ad8329c7..03f4e581d5 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -1636,7 +1636,7 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) switch (node->nsec) { case DNS_RBT_NSEC_NORMAL: #ifdef BIND9 - if (rbtdb->rpz_cidr != NULL) { + if (rbtdb->rpz_cidr != NULL && node->rpz) { dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); dns_rbt_fullnamefromnode(node, name); @@ -1677,7 +1677,7 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) } } #ifdef BIND9 - if (rbtdb->rpz_cidr != NULL) + if (rbtdb->rpz_cidr != NULL && node->rpz) dns_rpz_cidr_deleteip(rbtdb->rpz_cidr, name); #endif result = dns_rbt_deletenode(rbtdb->tree, node, ISC_FALSE); @@ -2679,6 +2679,7 @@ findnodeintree(dns_rbtdb_t *rbtdb, dns_rbt_t *tree, dns_name_t *name, fname = dns_fixedname_name(&fnamef); dns_rbt_fullnamefromnode(node, fname); dns_rpz_cidr_addip(rbtdb->rpz_cidr, fname); + node->rpz = 1; } #endif dns_rbt_namefromnode(node, &nodename); @@ -7099,7 +7100,6 @@ loadnode(dns_rbtdb_t *rbtdb, dns_name_t *name, dns_rbtnode_t **nodep, "dns_rbt_addnode(NSEC): %s", isc_result_totext(tmpresult), isc_result_totext(noderesult)); - } /* @@ -7109,8 +7109,10 @@ loadnode(dns_rbtdb_t *rbtdb, dns_name_t *name, dns_rbtnode_t **nodep, done: #ifdef BIND9 - if (noderesult == ISC_R_SUCCESS && rbtdb->rpz_cidr != NULL) + if (noderesult == ISC_R_SUCCESS && rbtdb->rpz_cidr != NULL) { dns_rpz_cidr_addip(rbtdb->rpz_cidr, name); + node->rpz = 1; + } #endif if (noderesult == ISC_R_SUCCESS || noderesult == ISC_R_EXISTS) *nodep = node;