From b735f2e821f77de088efd3d516a29243c504affb Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 4 Mar 2025 12:54:33 -0800 Subject: [PATCH] fixup! refactor validated() --- lib/dns/resolver.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 7006bd4f08..ac0ed8e09e 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -5910,7 +5910,7 @@ check_cacheable(dns_name_t *name, dns_rdataset_t *rdataset, bool fail) { } static void -fixttls(dns_view_t *view, dns_rdataset_t *set, dns_rdataset_t *sigset) { +fixttl(dns_view_t *view, dns_rdataset_t *set) { /* * Enforce the configured maximum and minimum cache TTL. */ @@ -5928,14 +5928,6 @@ fixttls(dns_view_t *view, dns_rdataset_t *set, dns_rdataset_t *sigset) { if (set->ttl >= view->prefetch_eligible) { set->attributes |= DNS_RDATASETATTR_PREFETCH; } - - /* - * Normalize the rdataset and sigrdataset TTLs. - */ - if (sigset != NULL) { - set->ttl = ISC_MIN(set->ttl, sigset->ttl); - sigset->ttl = set->ttl; - } } static isc_result_t @@ -6144,22 +6136,25 @@ rctx_cachename(respctx_t *rctx, dns_message_t *message, dns_name_t *name) { } /* - * Find the RRSIG for this rdataset, if we have it. + * Make the TTL consistent with the configured + * maximum and minimum */ - sigrdataset = getrrsig(name, rdataset->type); - - /* - * Make the TTLs consistent with the configured - * maximum and minimum and with each other. - */ - fixttls(res->view, rdataset, sigrdataset); + fixttl(res->view, rdataset); if (secure_domain && gettrust(rdataset) != dns_trust_glue) { /* * If this is a secure domain and the rdataset * isn't glue, start a validator. The data will - * be cached when the validator finishes. + * be cached when the validator finishes. First, + * find the RRSIG and normalize the TTLs. */ + sigrdataset = getrrsig(name, rdataset->type); + if (sigrdataset != NULL) { + rdataset->ttl = ISC_MIN(rdataset->ttl, + sigrdataset->ttl); + sigrdataset->ttl = rdataset->ttl; + } + result = rctx_cache_secure(rctx, message, name, node, rdataset, sigrdataset, need_validation);