From: Ondřej Surý Date: Wed, 6 Aug 2025 17:34:35 +0000 (+0200) Subject: Unify the dns_typepair_t variable naming and usage X-Git-Tag: v9.21.12~44^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=101b1e5a5709cd788089515c3af870bcaa671384;p=thirdparty%2Fbind9.git Unify the dns_typepair_t variable naming and usage The dns_typepair_t and dns_rdatatype_t variables were both named 'type' in multiple places. Rename all dns_typepair_t variables to include word 'pair' in the variable name to make sure that the distinction between the two types is more clear. --- diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h index 921c32da1f5..c5e61c3b925 100644 --- a/lib/dns/include/dns/rdataslab.h +++ b/lib/dns/include/dns/rdataslab.h @@ -76,7 +76,7 @@ struct dns_slabheader { isc_stdtime_t expire; dns_ttl_t ttl; }; - dns_typepair_t type; + dns_typepair_t typepair; _Atomic(uint16_t) count; /*%< diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index 29f93355465..0f10245aa4c 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -826,13 +826,13 @@ unref: } static void -update_rrsetstats(dns_stats_t *stats, const dns_typepair_t htype, +update_rrsetstats(dns_stats_t *stats, const dns_typepair_t typepair, const uint_least16_t hattributes, const bool increment) { dns_rdatastatstype_t statattributes = 0; dns_rdatastatstype_t base = 0; dns_rdatastatstype_t type; dns_slabheader_t *header = &(dns_slabheader_t){ - .type = htype, + .typepair = typepair, .attributes = hattributes, }; @@ -845,10 +845,10 @@ update_rrsetstats(dns_stats_t *stats, const dns_typepair_t htype, statattributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN; } else { statattributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET; - base = DNS_TYPEPAIR_COVERS(header->type); + base = DNS_TYPEPAIR_COVERS(header->typepair); } } else { - base = DNS_TYPEPAIR_TYPE(header->type); + base = DNS_TYPEPAIR_TYPE(header->typepair); } if (STALE(header)) { @@ -890,8 +890,8 @@ mark(dns_slabheader_t *header, uint_least16_t flag) { */ stats = dns_db_getrrsetstats(&qpdb->common); if (stats != NULL) { - update_rrsetstats(stats, header->type, attributes, false); - update_rrsetstats(stats, header->type, newattributes, true); + update_rrsetstats(stats, header->typepair, attributes, false); + update_rrsetstats(stats, header->typepair, newattributes, true); } } @@ -1038,8 +1038,8 @@ bindrdataset(qpcache_t *qpdb, qpcnode_t *node, dns_slabheader_t *header, rdataset->methods = &dns_rdataslab_rdatasetmethods; rdataset->rdclass = qpdb->common.rdclass; - rdataset->type = DNS_TYPEPAIR_TYPE(header->type); - rdataset->covers = DNS_TYPEPAIR_COVERS(header->type); + rdataset->type = DNS_TYPEPAIR_TYPE(header->typepair); + rdataset->covers = DNS_TYPEPAIR_COVERS(header->typepair); rdataset->ttl = !ZEROTTL(header) ? header->expire - now : 0; rdataset->trust = header->trust; rdataset->resign = 0; @@ -1115,7 +1115,7 @@ static isc_result_t setup_delegation(qpc_search_t *search, dns_dbnode_t **nodep, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset, isc_rwlocktype_t tlocktype DNS__DB_FLARG) { - dns_typepair_t type; + dns_typepair_t typepair; qpcnode_t *node = NULL; REQUIRE(search != NULL); @@ -1127,7 +1127,7 @@ setup_delegation(qpc_search_t *search, dns_dbnode_t **nodep, */ node = search->zonecut; - type = search->zonecut_header->type; + typepair = search->zonecut_header->typepair; if (nodep != NULL) { /* @@ -1150,7 +1150,7 @@ setup_delegation(qpc_search_t *search, dns_dbnode_t **nodep, NODE_UNLOCK(nlock, &nlocktype); } - if (type == dns_rdatatype_dname) { + if (typepair == dns_rdatatype_dname) { return DNS_R_DNAME; } return DNS_R_DELEGATION; @@ -1221,28 +1221,28 @@ check_stale_header(dns_slabheader_t *header, qpc_search_t *search, * negative header covering either 'negtype' or ANY. */ static bool -related_headers(dns_slabheader_t *header, dns_typepair_t type, - dns_typepair_t sigtype, dns_typepair_t negtype, +related_headers(dns_slabheader_t *header, dns_typepair_t typepair, + dns_typepair_t sigpair, dns_typepair_t negpair, dns_slabheader_t **foundp, dns_slabheader_t **foundsigp, bool *matchp) { if (!EXISTS(header) || ANCIENT(header)) { return false; } - if (header->type == type) { + if (header->typepair == typepair) { *foundp = header; SET_IF_NOT_NULL(matchp, true); if (*foundsigp != NULL) { return true; } - } else if (header->type == sigtype) { + } else if (header->typepair == sigpair) { *foundsigp = header; SET_IF_NOT_NULL(matchp, true); if (*foundp != NULL) { return true; } - } else if (negtype != 0 && (header->type == RDATATYPE_NCACHEANY || - header->type == negtype)) + } else if (negpair != 0 && (header->typepair == RDATATYPE_NCACHEANY || + header->typepair == negpair)) { *foundp = header; *foundsigp = NULL; @@ -1259,11 +1259,11 @@ related_headers(dns_slabheader_t *header, dns_typepair_t type, static bool both_headers(dns_slabheader_t *header, dns_rdatatype_t type, dns_slabheader_t **foundp, dns_slabheader_t **foundsigp) { - dns_typepair_t matchtype = DNS_TYPEPAIR_VALUE(type, 0); - dns_typepair_t sigmatchtype = DNS_SIGTYPE(type); + dns_typepair_t typepair = DNS_TYPEPAIR_VALUE(type, 0); + dns_typepair_t sigpair = DNS_SIGTYPE(type); - return related_headers(header, matchtype, sigmatchtype, 0, foundp, - foundsigp, NULL); + return related_headers(header, typepair, sigpair, 0, foundp, foundsigp, + NULL); } static isc_result_t @@ -1463,7 +1463,7 @@ find_coveringnsec(qpc_search_t *search, const dns_name_t *name, continue; } - if (DNS_TYPEPAIR_TYPE(header->type) == 0) { + if (DNS_TYPEPAIR_TYPE(header->typepair) == 0) { continue; } @@ -1543,7 +1543,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, dns_slabheader_t *found = NULL, *nsheader = NULL; dns_slabheader_t *foundsig = NULL, *nssig = NULL, *cnamesig = NULL; dns_slabheader_t *nsecheader = NULL, *nsecsig = NULL; - dns_typepair_t sigtype, negtype; + dns_typepair_t typepair, sigpair, negpair; qpc_search_t search; qpc_search_init(&search, (qpcache_t *)db, options, __now); @@ -1601,7 +1601,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, */ if ((search.options & DNS_DBFIND_COVERINGNSEC) != 0 && (search.zonecut_header == NULL || - search.zonecut_header->type != dns_rdatatype_dname)) + search.zonecut_header->typepair != dns_rdatatype_dname)) { result = find_coveringnsec( &search, name, nodep, foundname, rdataset, @@ -1650,8 +1650,9 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, */ found = NULL; foundsig = NULL; - sigtype = DNS_SIGTYPE(type); - negtype = DNS_TYPEPAIR_VALUE(0, type); + typepair = DNS_TYPEPAIR_VALUE(type, 0); + sigpair = DNS_SIGTYPE(type); + negpair = DNS_TYPEPAIR_VALUE(0, type); nsheader = NULL; nsecheader = NULL; nssig = NULL; @@ -1686,7 +1687,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, } bool match = false; - if (related_headers(header, type, sigtype, negtype, &found, + if (related_headers(header, typepair, sigpair, negpair, &found, &foundsig, &match) && !MISSING_ANSWER(found, options)) { @@ -1705,7 +1706,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, continue; } - switch (header->type) { + switch (header->typepair) { case dns_rdatatype_cname: if (!cname_ok) { break; @@ -1717,7 +1718,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, foundsig = cnamesig; } else { /* Look for CNAME signature instead */ - sigtype = DNS_SIGTYPE(dns_rdatatype_cname); + sigpair = DNS_SIGTYPE(dns_rdatatype_cname); foundsig = NULL; } break; @@ -1745,8 +1746,8 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, break; default: - if (type == dns_rdatatype_any && - DNS_TYPEPAIR_TYPE(header->type) != 0) + if (typepair == dns_rdatatype_any && + DNS_TYPEPAIR_TYPE(header->typepair) != 0) { /* QTYPE==ANY, so any anwers will do */ found = header; @@ -1854,8 +1855,9 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, } else { result = DNS_R_NCACHENXRRSET; } - } else if (type != found->type && type != dns_rdatatype_any && - found->type == dns_rdatatype_cname) + } else if (typepair != found->typepair && + typepair != dns_rdatatype_any && + found->typepair == dns_rdatatype_cname) { /* * We weren't doing an ANY query and we found a CNAME instead @@ -1870,7 +1872,7 @@ qpcache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, result = ISC_R_SUCCESS; } - if (type != dns_rdatatype_any || result == DNS_R_NCACHENXDOMAIN || + if (typepair != dns_rdatatype_any || result == DNS_R_NCACHENXDOMAIN || result == DNS_R_NCACHENXRRSET) { bindrdatasets(search.qpdb, node, found, foundsig, search.now, @@ -1919,8 +1921,8 @@ seek_ns_headers(qpc_search_t *search, qpcnode_t *node, dns_dbnode_t **nodep, for (header = node->data; header != NULL; header = header_next) { header_next = header->next; - bool ns = (header->type == dns_rdatatype_ns || - header->type == DNS_SIGTYPE(dns_rdatatype_ns)); + bool ns = (header->typepair == dns_rdatatype_ns || + header->typepair == DNS_SIGTYPE(dns_rdatatype_ns)); if (check_stale_header(header, search, &header_prev)) { if (ns) { /* @@ -2063,7 +2065,7 @@ qpcache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, dns_slabheader_t *header = NULL; dns_slabheader_t *header_prev = NULL, *header_next = NULL; dns_slabheader_t *found = NULL, *foundsig = NULL; - dns_typepair_t matchtype, sigmatchtype, negtype; + dns_typepair_t typepair, sigpair, negpair; isc_result_t result; isc_rwlock_t *nlock = NULL; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; @@ -2081,9 +2083,9 @@ qpcache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, nlock = &qpdb->buckets[qpnode->locknum].lock; NODE_RDLOCK(nlock, &nlocktype); - matchtype = DNS_TYPEPAIR_VALUE(type, covers); - negtype = DNS_TYPEPAIR_VALUE(0, type); - sigmatchtype = (covers == 0) ? DNS_SIGTYPE(type) : 0; + typepair = DNS_TYPEPAIR_VALUE(type, covers); + negpair = DNS_TYPEPAIR_VALUE(0, type); + sigpair = (covers == 0) ? DNS_SIGTYPE(type) : 0; for (header = qpnode->data; header != NULL; header = header_next) { header_next = header->next; @@ -2092,8 +2094,8 @@ qpcache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, continue; } - if (related_headers(header, matchtype, sigmatchtype, negtype, - &found, &foundsig, NULL)) + if (related_headers(header, typepair, sigpair, negpair, &found, + &foundsig, NULL)) { break; } @@ -2482,11 +2484,13 @@ overmaxtype(qpcache_t *qpdb, uint32_t ntypes) { static bool prio_header(dns_slabheader_t *header) { - if (NEGATIVE(header) && prio_type(DNS_TYPEPAIR_COVERS(header->type))) { + if (NEGATIVE(header) && + prio_type(DNS_TYPEPAIR_COVERS(header->typepair))) + { return true; } - return prio_type(header->type); + return prio_type(header->typepair); } static void @@ -2543,7 +2547,7 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, dns_slabheader_t *topheader = NULL, *topheader_prev = NULL; dns_slabheader_t *header = NULL, *sigheader = NULL; dns_slabheader_t *prioheader = NULL, *expireheader = NULL; - dns_typepair_t negtype = 0; + dns_typepair_t negpair = 0; dns_trust_t trust; uint32_t ntypes = 0; @@ -2554,9 +2558,10 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, } if (EXISTS(newheader)) { - dns_rdatatype_t rdtype = DNS_TYPEPAIR_TYPE(newheader->type); - dns_rdatatype_t covers = DNS_TYPEPAIR_COVERS(newheader->type); - dns_typepair_t sigtype = DNS_SIGTYPE(covers); + dns_rdatatype_t rdtype = DNS_TYPEPAIR_TYPE(newheader->typepair); + dns_rdatatype_t covers = + DNS_TYPEPAIR_COVERS(newheader->typepair); + dns_typepair_t sigpair = DNS_SIGTYPE(covers); if (NEGATIVE(newheader)) { /* * We're adding a negative cache entry. @@ -2586,12 +2591,12 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, for (topheader = qpnode->data; topheader != NULL; topheader = topheader->next) { - if (topheader->type == sigtype) { + if (topheader->typepair == sigpair) { sigheader = topheader; break; } } - negtype = DNS_TYPEPAIR_VALUE(covers, 0); + negpair = DNS_TYPEPAIR_VALUE(covers, 0); } else { /* * We're adding something that isn't a @@ -2604,9 +2609,10 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, for (topheader = qpnode->data; topheader != NULL; topheader = topheader->next) { - if ((topheader->type == RDATATYPE_NCACHEANY) || - (newheader->type == sigtype && - topheader->type == + if ((topheader->typepair == + RDATATYPE_NCACHEANY) || + (newheader->typepair == sigpair && + topheader->typepair == DNS_TYPEPAIR_VALUE(0, covers))) { break; @@ -2642,7 +2648,7 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, topheader = NULL; goto find_header; } - negtype = DNS_TYPEPAIR_VALUE(0, rdtype); + negpair = DNS_TYPEPAIR_VALUE(0, rdtype); } } @@ -2657,8 +2663,8 @@ add(qpcache_t *qpdb, qpcnode_t *qpnode, prioheader = topheader; } - if (topheader->type == newheader->type || - topheader->type == negtype) + if (topheader->typepair == newheader->typepair || + topheader->typepair == negpair) { break; } @@ -2706,12 +2712,12 @@ find_header: * special to be done w.r.t stale data; it gets replaced * normally further down. */ - if (ACTIVE(header, now) && header->type == dns_rdatatype_ns && - EXISTS(header) && EXISTS(newheader) && - header->trust >= newheader->trust && + if (ACTIVE(header, now) && + header->typepair == dns_rdatatype_ns && EXISTS(header) && + EXISTS(newheader) && header->trust >= newheader->trust && dns_rdataslab_equalx(header, newheader, qpdb->common.rdclass, - (dns_rdatatype_t)header->type)) + DNS_TYPEPAIR_TYPE(header->typepair))) { /* * Honour the new ttl if it is less than the @@ -2749,9 +2755,9 @@ find_header: * to be no more than the current NS RRset's TTL. This * ensures the delegations that are withdrawn are honoured. */ - if (ACTIVE(header, now) && header->type == dns_rdatatype_ns && - EXISTS(header) && EXISTS(newheader) && - header->trust <= newheader->trust) + if (ACTIVE(header, now) && + header->typepair == dns_rdatatype_ns && EXISTS(header) && + EXISTS(newheader) && header->trust <= newheader->trust) { if (newheader->expire > header->expire) { newheader->expire = header->expire; @@ -2759,10 +2765,10 @@ find_header: } if (ACTIVE(header, now) && (options & DNS_DBADD_PREFETCH) == 0 && - (header->type == dns_rdatatype_a || - header->type == dns_rdatatype_aaaa || - header->type == dns_rdatatype_ds || - header->type == DNS_SIGTYPE(dns_rdatatype_ds)) && + (header->typepair == dns_rdatatype_a || + header->typepair == dns_rdatatype_aaaa || + header->typepair == dns_rdatatype_ds || + header->typepair == DNS_SIGTYPE(dns_rdatatype_ds)) && EXISTS(header) && EXISTS(newheader) && header->trust >= newheader->trust && dns_rdataslab_equal(header, newheader)) @@ -3068,7 +3074,7 @@ qpcache_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, if (qpdb->rrsetstats != NULL) { DNS_SLABHEADER_SETATTR(newheader, DNS_SLABHEADERATTR_STATCOUNT); - update_rrsetstats(qpdb->rrsetstats, newheader->type, + update_rrsetstats(qpdb->rrsetstats, newheader->typepair, atomic_load_acquire(&newheader->attributes), true); } @@ -3132,7 +3138,7 @@ qpcache_deleterdataset(dns_db_t *db, dns_dbnode_t *node, } newheader = dns_slabheader_new(db, node); - newheader->type = DNS_TYPEPAIR_VALUE(type, covers); + newheader->typepair = DNS_TYPEPAIR_VALUE(type, covers); setttl(newheader, 0); atomic_init(&newheader->attributes, DNS_SLABHEADERATTR_NONEXISTENT); @@ -3742,7 +3748,7 @@ qpcnode_deletedata(dns_dbnode_t *node ISC_ATTR_UNUSED, void *data) { isc_heap_delete(header->heap, header->heap_index); } - update_rrsetstats(qpdb->rrsetstats, header->type, + update_rrsetstats(qpdb->rrsetstats, header->typepair, atomic_load_acquire(&header->attributes), false); if (ISC_LINK_LINKED(header, link)) { diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 2140a964215..8253d21dde5 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -445,7 +445,7 @@ resign_sooner(void *v1, void *v2) { return h1->resign < h2->resign || (h1->resign == h2->resign && h1->resign_lsb < h2->resign_lsb) || (h1->resign == h2->resign && h1->resign_lsb == h2->resign_lsb && - h2->type == DNS_SIGTYPE(dns_rdatatype_soa)); + h2->typepair == DNS_SIGTYPE(dns_rdatatype_soa)); } /*% @@ -1059,8 +1059,8 @@ bindrdataset(qpzonedb_t *qpdb, qpznode_t *node, dns_slabheader_t *header, rdataset->methods = &dns_rdataslab_rdatasetmethods; rdataset->rdclass = qpdb->common.rdclass; - rdataset->type = DNS_TYPEPAIR_TYPE(header->type); - rdataset->covers = DNS_TYPEPAIR_COVERS(header->type); + rdataset->type = DNS_TYPEPAIR_TYPE(header->typepair); + rdataset->covers = DNS_TYPEPAIR_COVERS(header->typepair); rdataset->ttl = header->ttl; rdataset->trust = header->trust; @@ -1133,7 +1133,7 @@ setnsec3parameters(dns_db_t *db, qpz_version_t *version) { } while (header != NULL); if (header != NULL && - (header->type == dns_rdatatype_nsec3param)) + (header->typepair == dns_rdatatype_nsec3param)) { /* * Find an NSEC3PARAM with a supported algorithm. @@ -1623,7 +1623,7 @@ qpzone_findrdataset(dns_db_t *db, dns_dbnode_t *dbnode, uint32_t serial; qpz_version_t *version = (qpz_version_t *)dbversion; bool close_version = false; - dns_typepair_t matchtype, sigmatchtype; + dns_typepair_t typepair, sigpair; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; isc_rwlock_t *nlock = NULL; @@ -1640,11 +1640,11 @@ qpzone_findrdataset(dns_db_t *db, dns_dbnode_t *dbnode, nlock = qpzone_get_lock(node); NODE_RDLOCK(nlock, &nlocktype); - matchtype = DNS_TYPEPAIR_VALUE(type, covers); + typepair = DNS_TYPEPAIR_VALUE(type, covers); if (covers == 0) { - sigmatchtype = DNS_SIGTYPE(type); + sigpair = DNS_SIGTYPE(type); } else { - sigmatchtype = 0; + sigpair = 0; } for (header = node->data; header != NULL; header = header_next) { @@ -1664,12 +1664,12 @@ qpzone_findrdataset(dns_db_t *db, dns_dbnode_t *dbnode, * We have an active, extant rdataset. If it's a * type we're looking for, remember it. */ - if (header->type == matchtype) { + if (header->typepair == typepair) { found = header; if (foundsig != NULL) { break; } - } else if (header->type == sigmatchtype) { + } else if (header->typepair == sigpair) { foundsig = header; if (found != NULL) { break; @@ -1700,9 +1700,9 @@ qpzone_findrdataset(dns_db_t *db, dns_dbnode_t *dbnode, } static bool -delegating_type(qpzonedb_t *qpdb, qpznode_t *node, dns_typepair_t type) { - return type == dns_rdatatype_dname || - (type == dns_rdatatype_ns && +delegating_type(qpzonedb_t *qpdb, qpznode_t *node, dns_typepair_t typepair) { + return typepair == dns_rdatatype_dname || + (typepair == dns_rdatatype_ns && (node != qpdb->origin || IS_STUB(qpdb))); } @@ -1778,7 +1778,7 @@ cname_and_other(qpznode_t *node, uint32_t serial) { for (header = node->data; header != NULL; header = header_next) { header_next = header->next; - rdtype = DNS_TYPEPAIR_TYPE(header->type); + rdtype = DNS_TYPEPAIR_TYPE(header->typepair); if (rdtype == dns_rdatatype_cname) { do { if (header->serial <= serial && !IGNORE(header)) @@ -1809,7 +1809,7 @@ cname_and_other(qpznode_t *node, uint32_t serial) { header = header->down; } while (header != NULL); if (header != NULL) { - if (!prio_type(header->type)) { + if (!prio_type(header->typepair)) { /* * CNAME is in the priority list, so if * we are done with priority types, we @@ -1906,10 +1906,10 @@ add(qpzonedb_t *qpdb, qpznode_t *node, const dns_name_t *nodename, topheader = topheader->next) { ++ntypes; - if (prio_type(topheader->type)) { + if (prio_type(topheader->typepair)) { prioheader = topheader; } - if (topheader->type == newheader->type) { + if (topheader->typepair == newheader->typepair) { break; } topheader_prev = topheader; @@ -1950,8 +1950,8 @@ add(qpzonedb_t *qpdb, qpznode_t *node, const dns_name_t *nodename, result = dns_rdataslab_merge( header, newheader, qpdb->common.mctx, qpdb->common.rdclass, - (dns_rdatatype_t)header->type, flags, - qpdb->maxrrperset, &merged); + DNS_TYPEPAIR_TYPE(header->typepair), + flags, qpdb->maxrrperset, &merged); } if (result == ISC_R_SUCCESS) { /* @@ -1979,7 +1979,8 @@ add(qpzonedb_t *qpdb, qpznode_t *node, const dns_name_t *nodename, if (result == DNS_R_TOOMANYRECORDS) { dns__db_logtoomanyrecords( (dns_db_t *)qpdb, nodename, - (dns_rdatatype_t)header->type, + DNS_TYPEPAIR_TYPE( + header->typepair), "updating", qpdb->maxrrperset); } dns_slabheader_destroy(&newheader); @@ -2085,7 +2086,7 @@ add(qpzonedb_t *qpdb, qpznode_t *node, const dns_name_t *nodename, INSIST(newheader->down == NULL); - if (prio_type(newheader->type)) { + if (prio_type(newheader->typepair)) { /* This is a priority type, prepend it */ newheader->next = node->data; node->data = newheader; @@ -2522,7 +2523,7 @@ again: ? (header->resign << 1) | header->resign_lsb : 0; dns_name_copy(&HEADERNODE(header)->name, foundname); - *typepair = header->type; + *typepair = header->typepair; result = ISC_R_SUCCESS; } UNLOCK(&qpdb->heap->lock); @@ -2627,7 +2628,7 @@ matchparams(dns_slabheader_t *header, qpz_search_t *search) { isc_region_t region; isc_result_t result; - REQUIRE(header->type == dns_rdatatype_nsec3); + REQUIRE(header->typepair == dns_rdatatype_nsec3); raw = (unsigned char *)header + sizeof(*header); count = raw[0] * 256 + raw[1]; /* count */ @@ -2661,7 +2662,7 @@ qpzone_setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep, dns_name_t *foundname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG) { dns_name_t *zcname = NULL; - dns_typepair_t type; + dns_typepair_t typepair; qpznode_t *node = NULL; REQUIRE(search != NULL); @@ -2673,7 +2674,7 @@ qpzone_setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep, */ node = search->zonecut; - type = search->zonecut_header->type; + typepair = search->zonecut_header->typepair; /* * If we have to set foundname, we do it before anything else. @@ -2709,7 +2710,7 @@ qpzone_setup_delegation(qpz_search_t *search, dns_dbnode_t **nodep, NODE_UNLOCK(nlock, &nlocktype); } - if (type == dns_rdatatype_dname) { + if (typepair == dns_rdatatype_dname) { return DNS_R_DNAME; } return DNS_R_DELEGATION; @@ -3103,18 +3104,14 @@ find_closest_nsec(qpz_search_t *search, dns_dbnode_t **nodep, isc_result_t result; dns_fixedname_t fname; dns_name_t *name = dns_fixedname_initname(&fname); - dns_rdatatype_t type = dns_rdatatype_nsec; - dns_typepair_t sigtype = DNS_SIGTYPE(dns_rdatatype_nsec); - bool wraps = false; + dns_rdatatype_t matchtype = nsec3 ? dns_rdatatype_nsec3 + : dns_rdatatype_nsec; + dns_typepair_t typepair = DNS_TYPEPAIR_VALUE(matchtype, 0); + dns_typepair_t sigpair = DNS_SIGTYPE(matchtype); + bool wraps = nsec3; bool first = true; bool need_sig = secure; - if (nsec3) { - type = dns_rdatatype_nsec3; - sigtype = DNS_SIGTYPE(dns_rdatatype_nsec3); - wraps = true; - } - /* * Use the auxiliary tree only starting with the second node in the * hope that the original node will be right much of the time. @@ -3154,12 +3151,12 @@ again: * active rdataset at this node. */ empty_node = false; - if (header->type == type) { + if (header->typepair == typepair) { found = header; if (foundsig != NULL) { break; } - } else if (header->type == sigtype) { + } else if (header->typepair == sigpair) { foundsig = header; if (found != NULL) { break; @@ -3169,13 +3166,13 @@ again: } if (!empty_node) { if (found != NULL && search->version->havensec3 && - found->type == dns_rdatatype_nsec3 && + found->typepair == dns_rdatatype_nsec3 && !matchparams(found, search)) { empty_node = true; found = NULL; foundsig = NULL; - result = previous_closest_nsec(type, search, + result = previous_closest_nsec(typepair, search, name, &prevnode, NULL, NULL); } else if (found != NULL && @@ -3214,7 +3211,7 @@ again: */ empty_node = true; result = previous_closest_nsec( - type, search, name, &prevnode, + typepair, search, name, &prevnode, &nseciter, &first); } else { /* @@ -3229,7 +3226,7 @@ again: * This node isn't active. We've got to keep * looking. */ - result = previous_closest_nsec(type, search, name, + result = previous_closest_nsec(typepair, search, name, &prevnode, &nseciter, &first); } @@ -3277,9 +3274,9 @@ qpzone_check_zonecut(qpznode_t *node, void *arg DNS__DB_FLARG) { */ for (header = node->data; header != NULL; header = header_next) { header_next = header->next; - if (header->type == dns_rdatatype_ns || - header->type == dns_rdatatype_dname || - header->type == DNS_SIGTYPE(dns_rdatatype_dname)) + if (header->typepair == dns_rdatatype_ns || + header->typepair == dns_rdatatype_dname || + header->typepair == DNS_SIGTYPE(dns_rdatatype_dname)) { do { if (header->serial <= search->serial && @@ -3294,9 +3291,9 @@ qpzone_check_zonecut(qpznode_t *node, void *arg DNS__DB_FLARG) { } } while (header != NULL); if (header != NULL) { - if (header->type == dns_rdatatype_dname) { + if (header->typepair == dns_rdatatype_dname) { dname_header = header; - } else if (header->type == + } else if (header->typepair == DNS_SIGTYPE(dns_rdatatype_dname)) { sigdname_header = header; @@ -3429,7 +3426,7 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, dns_slabheader_t *header = NULL, *header_next = NULL; dns_slabheader_t *found = NULL, *nsecheader = NULL; dns_slabheader_t *foundsig = NULL, *cnamesig = NULL, *nsecsig = NULL; - dns_typepair_t sigtype; + dns_typepair_t sigpair; bool active; isc_rwlock_t *nlock = NULL; isc_rwlocktype_t nlocktype = isc_rwlocktype_none; @@ -3602,7 +3599,7 @@ found: * We now go looking for rdata... */ - sigtype = DNS_SIGTYPE(type); + sigpair = DNS_SIGTYPE(type); empty_node = true; for (header = node->data; header != NULL; header = header_next) { header_next = header->next; @@ -3630,7 +3627,9 @@ found: /* * Do special zone cut handling, if requested. */ - if (maybe_zonecut && header->type == dns_rdatatype_ns) { + if (maybe_zonecut && + header->typepair == dns_rdatatype_ns) + { /* * We increment the reference count on node to * ensure that search->zonecut_header will @@ -3671,7 +3670,7 @@ found: * If the NSEC3 record doesn't match the chain * we are using behave as if it isn't here. */ - if (header->type == dns_rdatatype_nsec3 && + if (header->typepair == dns_rdatatype_nsec3 && !matchparams(header, &search)) { NODE_UNLOCK(nlock, &nlocktype); @@ -3681,14 +3680,16 @@ found: * If we found a type we were looking for, * remember it. */ - if (header->type == type || type == dns_rdatatype_any || - (header->type == dns_rdatatype_cname && cname_ok)) + if (header->typepair == type || + type == dns_rdatatype_any || + (header->typepair == dns_rdatatype_cname && + cname_ok)) { /* * We've found the answer! */ found = header; - if (header->type == dns_rdatatype_cname && + if (header->typepair == dns_rdatatype_cname && cname_ok) { /* @@ -3702,7 +3703,7 @@ found: if (cnamesig != NULL) { foundsig = cnamesig; } else { - sigtype = DNS_SIGTYPE( + sigpair = DNS_SIGTYPE( dns_rdatatype_cname); } } @@ -3712,7 +3713,7 @@ found: if (!maybe_zonecut && foundsig != NULL) { break; } - } else if (header->type == sigtype) { + } else if (header->typepair == sigpair) { /* * We've found the RRSIG rdataset for our * target type. Remember it. @@ -3724,7 +3725,7 @@ found: if (!maybe_zonecut && found != NULL) { break; } - } else if (header->type == dns_rdatatype_nsec && + } else if (header->typepair == dns_rdatatype_nsec && !search.version->havensec3) { /* @@ -3733,7 +3734,7 @@ found: * we might need it later. */ nsecheader = header; - } else if (header->type == + } else if (header->typepair == DNS_SIGTYPE(dns_rdatatype_nsec) && !search.version->havensec3) { @@ -3743,7 +3744,7 @@ found: */ nsecsig = header; } else if (cname_ok && - header->type == + header->typepair == DNS_SIGTYPE(dns_rdatatype_cname)) { /* @@ -3840,8 +3841,8 @@ found: /* * We found what we were looking for, or we found a CNAME. */ - if (type != found->type && type != dns_rdatatype_any && - found->type == dns_rdatatype_cname) + if (type != found->typepair && type != dns_rdatatype_any && + found->typepair == dns_rdatatype_cname) { /* * We weren't doing an ANY query and we found a CNAME instead @@ -4975,7 +4976,7 @@ qpzone_subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, for (topheader = node->data; topheader != NULL; topheader = topheader->next) { - if (topheader->type == newheader->type) { + if (topheader->typepair == newheader->typepair) { break; } topheader_prev = topheader; @@ -5003,7 +5004,7 @@ qpzone_subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, result = dns_rdataslab_subtract( header, newheader, qpdb->common.mctx, qpdb->common.rdclass, - (dns_rdatatype_t)header->type, flags, + DNS_TYPEPAIR_TYPE(header->typepair), flags, &subresult); } if (result == ISC_R_SUCCESS) { @@ -5040,7 +5041,7 @@ qpzone_subtractrdataset(dns_db_t *db, dns_dbnode_t *dbnode, newheader = dns_slabheader_new((dns_db_t *)qpdb, (dns_dbnode_t *)node); newheader->ttl = 0; - newheader->type = topheader->type; + newheader->typepair = topheader->typepair; atomic_init(&newheader->attributes, DNS_SLABHEADERATTR_NONEXISTENT); newheader->serial = version->serial; @@ -5122,7 +5123,7 @@ qpzone_deleterdataset(dns_db_t *db, dns_dbnode_t *dbnode, } newheader = dns_slabheader_new(db, (dns_dbnode_t *)node); - newheader->type = DNS_TYPEPAIR_VALUE(type, covers); + newheader->typepair = DNS_TYPEPAIR_VALUE(type, covers); newheader->ttl = 0; atomic_init(&newheader->attributes, DNS_SLABHEADERATTR_NONEXISTENT); newheader->serial = version->serial; diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 68f5ea66962..9f862422b93 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -346,8 +346,8 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, dns_slabheader_t *new = (dns_slabheader_t *)region->base; *new = (dns_slabheader_t){ - .type = DNS_TYPEPAIR_VALUE(rdataset->type, - rdataset->covers), + .typepair = DNS_TYPEPAIR_VALUE(rdataset->type, + rdataset->covers), .trust = rdataset->trust, .ttl = rdataset->ttl, .link = ISC_LINK_INITIALIZER, @@ -934,24 +934,24 @@ dns_slabheader_freeproof(isc_mem_t *mctx, dns_slabheader_proof_t **proofp) { dns_slabheader_t * dns_slabheader_top(dns_slabheader_t *header) { - dns_typepair_t type, negtype; + dns_typepair_t typepair, negpair; dns_rdatatype_t rdtype, covers; - type = header->type; - rdtype = DNS_TYPEPAIR_TYPE(header->type); + typepair = header->typepair; + rdtype = DNS_TYPEPAIR_TYPE(header->typepair); if (NEGATIVE(header)) { - covers = DNS_TYPEPAIR_COVERS(header->type); - negtype = DNS_TYPEPAIR_VALUE(covers, 0); + covers = DNS_TYPEPAIR_COVERS(header->typepair); + negpair = DNS_TYPEPAIR_VALUE(covers, 0); } else { - negtype = DNS_TYPEPAIR_VALUE(0, rdtype); + negpair = DNS_TYPEPAIR_VALUE(0, rdtype); } /* * Find the start of the header chain for the next type * by walking back up the list. */ - while (header->up != NULL && - (header->up->type == type || header->up->type == negtype)) + while (header->up != NULL && (header->up->typepair == typepair || + header->up->typepair == negpair)) { header = header->up; }