diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 11:55:57 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 11:55:57 +0000 |
| commit | 2bda7bda432fb0f867072224dd97e10435c8ad94 (patch) | |
| tree | 7ebfd82c2302bee4f9c05fb516c030153fb371d8 /services/cache | |
| parent | a6c5280ea59f940be13fd6eb0f94ab8360d3d6c9 (diff) | |
Notes
Diffstat (limited to 'services/cache')
| -rw-r--r-- | services/cache/dns.c | 10 | ||||
| -rw-r--r-- | services/cache/dns.h | 13 |
2 files changed, 16 insertions, 7 deletions
diff --git a/services/cache/dns.c b/services/cache/dns.c index da43c504dfa3..f9dc5922f682 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -111,7 +111,7 @@ store_rrsets(struct module_env* env, struct reply_info* rep, time_t now, void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, hashvalue_type hash, struct reply_info* rep, time_t leeway, int pside, - struct reply_info* qrep, struct regional* region) + struct reply_info* qrep, uint32_t flags, struct regional* region) { struct msgreply_entry* e; time_t ttl = rep->ttl; @@ -127,7 +127,7 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, * unnecessary, because the cache gets locked per rrset. */ reply_info_set_ttls(rep, *env->now); store_rrsets(env, rep, *env->now, leeway, pside, qrep, region); - if(ttl == 0) { + if(ttl == 0 && !(flags & DNSCACHE_STORE_ZEROTTL)) { /* we do not store the message, but we did store the RRs, * which could be useful for delegation information */ verbose(VERB_ALGO, "TTL 0: dropped msg from cache"); @@ -845,7 +845,7 @@ dns_cache_lookup(struct module_env* env, int dns_cache_store(struct module_env* env, struct query_info* msgqinf, struct reply_info* msgrep, int is_referral, time_t leeway, int pside, - struct regional* region, uint16_t flags) + struct regional* region, uint32_t flags) { struct reply_info* rep = NULL; /* alloc, malloc properly (not in region, like msg is) */ @@ -890,9 +890,9 @@ dns_cache_store(struct module_env* env, struct query_info* msgqinf, * Not AA from cache. Not CD in cache (depends on client bit). */ rep->flags |= (BIT_RA | BIT_QR); rep->flags &= ~(BIT_AA | BIT_CD); - h = query_info_hash(&qinf, flags); + h = query_info_hash(&qinf, (uint16_t)flags); dns_cache_store_msg(env, &qinf, h, rep, leeway, pside, msgrep, - region); + flags, region); /* qname is used inside query_info_entrysetup, and set to * NULL. If it has not been used, free it. free(0) is safe. */ free(qinf.qname); diff --git a/services/cache/dns.h b/services/cache/dns.h index 096ddf28db63..9e10f437f1b4 100644 --- a/services/cache/dns.h +++ b/services/cache/dns.h @@ -49,6 +49,12 @@ struct reply_info; struct regional; struct delegpt; +/** Flags to control behavior of dns_cache_store() and dns_cache_store_msg(). + * Must be an unsigned 32-bit value larger than 0xffff */ + +/** Allow caching a DNS message with a zero TTL. */ +#define DNSCACHE_STORE_ZEROTTL 0x100000 + /** * Region allocated message reply */ @@ -80,11 +86,13 @@ struct dns_msg { * @param region: region to allocate better entries from cache into. * (used when is_referral is false). * @param flags: flags with BIT_CD for AAAA queries in dns64 translation. + * The higher 16 bits are used internally to customize the cache policy. + * (See DNSCACHE_STORE_xxx flags). * @return 0 on alloc error (out of memory). */ int dns_cache_store(struct module_env* env, struct query_info* qinf, struct reply_info* rep, int is_referral, time_t leeway, int pside, - struct regional* region, uint16_t flags); + struct regional* region, uint32_t flags); /** * Store message in the cache. Stores in message cache and rrset cache. @@ -103,11 +111,12 @@ int dns_cache_store(struct module_env* env, struct query_info* qinf, * from the parentside of the zonecut. This means that the type NS * can be updated to full TTL even in prefetch situations. * @param qrep: message that can be altered with better rrs from cache. + * @param flags: customization flags for the cache policy. * @param region: to allocate into for qmsg. */ void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, hashvalue_type hash, struct reply_info* rep, time_t leeway, int pside, - struct reply_info* qrep, struct regional* region); + struct reply_info* qrep, uint32_t flags, struct regional* region); /** * Find a delegation from the cache. |
