rdataset->covers = DNS_TYPEPAIR_COVERS(header->typepair);
}
rdataset->ttl = !ZEROTTL(header) ? header->expire - now : 0;
- rdataset->trust = header->trust;
+ rdataset->trust = atomic_load(&header->trust);
rdataset->resign = 0;
if (NEGATIVE(header)) {
}
}
- if (found != NULL && (!DNS_TRUST_PENDING(found->trust) ||
+ if (found != NULL && (!DNS_TRUST_PENDING(atomic_load(&found->trust)) ||
(search->options & DNS_DBFIND_PENDINGOK) != 0))
{
/*
return result;
}
-#define MISSING_ANSWER(found, options) \
- ((found) == NULL || \
- (DNS_TRUST_ADDITIONAL((found)->trust) && \
- (((options) & DNS_DBFIND_ADDITIONALOK) == 0)) || \
- ((found)->trust == dns_trust_glue && \
- (((options) & DNS_DBFIND_GLUEOK) == 0)) || \
- (DNS_TRUST_PENDING((found)->trust) && \
- (((options) & DNS_DBFIND_PENDINGOK) == 0)))
+static inline bool
+missing_answer(dns_slabheader_t *found, unsigned int options) {
+ if (found == NULL) {
+ return true;
+ }
+
+ dns_trust_t trust = atomic_load(&found->trust);
+ return (DNS_TRUST_ADDITIONAL(trust) &&
+ (options & DNS_DBFIND_ADDITIONALOK) == 0) ||
+ (DNS_TRUST_GLUE(trust) && (options & DNS_DBFIND_GLUEOK) == 0) ||
+ (DNS_TRUST_PENDING(trust) &&
+ (options & DNS_DBFIND_PENDINGOK) == 0);
+}
static void
qpc_search_init(qpc_search_t *search, qpcache_t *db, unsigned int options,
empty_node = false;
if (header->noqname != NULL &&
- header->trust == dns_trust_secure)
+ atomic_load(&header->trust) == dns_trust_secure)
{
found_noqname = true;
}
bool match = false;
if (related_headers(header, typepair, sigpair, &found,
&foundsig, &match) &&
- !MISSING_ANSWER(found, options))
+ !missing_answer(found, options))
{
/*
* We can't exit early until we have an answer with
- * sufficient trust level, see MISSING_ANSWER() macro
- * for details, because we might need NS or NSEC
+ * sufficient trust level - see missing_answer()
+ * for details - because we might need NS or NSEC
* records.
*/
-
break;
}
/*
* If we didn't find what we were looking for...
*/
- if (MISSING_ANSWER(found, options)) {
+ if (missing_answer(found, options)) {
/*
* Return covering NODATA NSEC record.
*/
* data will supersede it below. Unclear what the best
* policy is here.
*/
- if (trust < oldheader->trust &&
+ dns_trust_t oldtrust = atomic_load(&oldheader->trust);
+ if (trust < oldtrust &&
(ACTIVE(oldheader, now) || !EXISTS(oldheader)))
{
qpcache_hit(qpdb, oldheader);
if (ACTIVE(oldheader, now) &&
oldheader->typepair == DNS_TYPEPAIR(dns_rdatatype_ns) &&
EXISTS(oldheader) && EXISTS(newheader) &&
- oldheader->trust >= newheader->trust &&
+ newheader->trust < oldtrust &&
oldheader->expire < newheader->expire &&
dns_rdataslab_equalx(
oldheader, newheader, qpdb->common.rdclass,
}
/*
- * If we will be replacing a NS RRset force its TTL
+ * If we will be replacing an NS RRset, force its TTL
* to be no more than the current NS RRset's TTL. This
* ensures the delegations that are withdrawn are honoured.
*/
if (ACTIVE(oldheader, now) &&
oldheader->typepair == DNS_TYPEPAIR(dns_rdatatype_ns) &&
EXISTS(oldheader) && EXISTS(newheader) &&
- oldheader->trust <= newheader->trust)
+ newheader->trust > oldtrust)
{
if (newheader->expire > oldheader->expire) {
if (ZEROTTL(oldheader)) {
oldheader->typepair ==
DNS_SIGTYPEPAIR(dns_rdatatype_ds)) &&
EXISTS(oldheader) && EXISTS(newheader) &&
- oldheader->trust >= newheader->trust &&
+ newheader->trust < oldtrust &&
oldheader->expire < newheader->expire &&
dns_rdataslab_equal(oldheader, newheader))
{
rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) {
dns_slabheader_t *header = dns_rdataset_getheader(rdataset);
- dns_db_locknode(header->node, isc_rwlocktype_write);
- header->trust = rdataset->trust = trust;
- dns_db_unlocknode(header->node, isc_rwlocktype_write);
+ rdataset->trust = trust;
+ atomic_store(&header->trust, trust);
}
static void
rdataset_clearprefetch(dns_rdataset_t *rdataset) {
dns_slabheader_t *header = dns_rdataset_getheader(rdataset);
- dns_db_locknode(header->node, isc_rwlocktype_write);
DNS_SLABHEADER_CLRATTR(header, DNS_SLABHEADERATTR_PREFETCH);
- dns_db_unlocknode(header->node, isc_rwlocktype_write);
}
static void