mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Apply floor of 60s to TTL of DNSKEY and DS records in cache.
Short TTLs and specifically zero TTLs can mess up DNSSEC validation.
This commit is contained in:
21
src/cache.c
21
src/cache.c
@@ -472,16 +472,29 @@ void cache_start_insert(void)
|
|||||||
struct crec *cache_insert(char *name, union all_addr *addr, unsigned short class,
|
struct crec *cache_insert(char *name, union all_addr *addr, unsigned short class,
|
||||||
time_t now, unsigned long ttl, unsigned int flags)
|
time_t now, unsigned long ttl, unsigned int flags)
|
||||||
{
|
{
|
||||||
/* Don't log DNSSEC records here, done elsewhere */
|
#ifdef HAVE_DNSSEC
|
||||||
if (flags & (F_IPV4 | F_IPV6 | F_CNAME | F_SRV))
|
if (flags & (F_DNSKEY | F_DS))
|
||||||
{
|
{
|
||||||
|
/* The DNSSEC validation process works by getting needed records into the
|
||||||
|
cache, then retrying the validation until they are all in place.
|
||||||
|
This can be messed up by very short TTLs, and _really_ messed up by
|
||||||
|
zero TTLs, so we force the TTL to be at least long enough to do a validation.
|
||||||
|
Ideally, we should use some kind of reference counting so that records are
|
||||||
|
locked until the validation that asked for them is complete, but this
|
||||||
|
is much easier, and just as effective. */
|
||||||
|
if (ttl < DNSSEC_MIN_TTL)
|
||||||
|
ttl = DNSSEC_MIN_TTL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Don't log DNSSEC records here, done elsewhere */
|
||||||
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
||||||
/* Don't mess with TTL for DNSSEC records. */
|
|
||||||
if (daemon->max_cache_ttl != 0 && daemon->max_cache_ttl < ttl)
|
if (daemon->max_cache_ttl != 0 && daemon->max_cache_ttl < ttl)
|
||||||
ttl = daemon->max_cache_ttl;
|
ttl = daemon->max_cache_ttl;
|
||||||
if (daemon->min_cache_ttl != 0 && daemon->min_cache_ttl > ttl)
|
if (daemon->min_cache_ttl != 0 && daemon->min_cache_ttl > ttl)
|
||||||
ttl = daemon->min_cache_ttl;
|
ttl = daemon->min_cache_ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return really_insert(name, addr, class, now, ttl, flags);
|
return really_insert(name, addr, class, now, ttl, flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
|
#define DHCP_PACKET_MAX 16384 /* hard limit on DHCP packet size */
|
||||||
#define SMALLDNAME 50 /* most domain names are smaller than this */
|
#define SMALLDNAME 50 /* most domain names are smaller than this */
|
||||||
#define CNAME_CHAIN 10 /* chains longer than this atr dropped for loop protection */
|
#define CNAME_CHAIN 10 /* chains longer than this atr dropped for loop protection */
|
||||||
|
#define DNSSEC_MIN_TTL 60 /* DNSKEY and DS records in cache last at least this long */
|
||||||
#define HOSTSFILE "/etc/hosts"
|
#define HOSTSFILE "/etc/hosts"
|
||||||
#define ETHERSFILE "/etc/ethers"
|
#define ETHERSFILE "/etc/ethers"
|
||||||
#define DEFLEASE 3600 /* default lease time, 1 hour */
|
#define DEFLEASE 3600 /* default lease time, 1 hour */
|
||||||
|
|||||||
Reference in New Issue
Block a user