diff options
Diffstat (limited to 'services/cache/dns.c')
| -rw-r--r-- | services/cache/dns.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/services/cache/dns.c b/services/cache/dns.c index 9fc79dad012c..04d5ae2d6302 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -43,6 +43,7 @@ #include "iterator/iter_utils.h" #include "validator/val_nsec.h" #include "validator/val_utils.h" +#include "iterator/iter_utils.h" #include "services/cache/dns.h" #include "services/cache/rrset.h" #include "util/data/msgparse.h" @@ -586,8 +587,12 @@ dns_cache_find_delegation(struct module_env* env, uint8_t* qname, return NULL; } } - if(!delegpt_rrset_add_ns(dp, region, nskey, 0)) + if(!delegpt_rrset_add_ns(dp, region, nskey, 0, + deleg_port_number(env))) { + lock_rw_unlock(&nskey->entry.lock); log_err("find_delegation: addns out of memory"); + return NULL; + } lock_rw_unlock(&nskey->entry.lock); /* first unlock before next lookup*/ /* find and add DS/NSEC (if any) */ if(msg) @@ -782,11 +787,16 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, uint8_t* newname, *dtarg = NULL; size_t newlen, dtarglen; time_t rr_ttl; + int graceperiod = 0; if(TTL_IS_EXPIRED(d->ttl, now)) { /* Allow TTL=0 DNAME from upstream within grace period */ if(!(rrset->rk.flags & PACKED_RRSET_UPSTREAM_0TTL)) return NULL; rr_ttl = 0; + /* Since PACKED_RRSET_UPSTREAM_0TTL set the flag that + * the grace period has been applied, this stops the rrset + * from getting stored back into the cache with a bigger TTL.*/ + graceperiod = 1; } else { rr_ttl = d->ttl - now; } @@ -814,6 +824,8 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, msg->rep->rrsets[0] = packed_rrset_copy_region(rrset, region, now); if(!msg->rep->rrsets[0]) /* copy DNAME */ return NULL; + if(graceperiod) + msg->rep->rrsets[0]->rk.flags |= PACKED_RRSET_0TTL_GRACE; /* synth CNAME rrset */ get_cname_target(rrset, &dtarg, &dtarglen); if(!dtarg) |
