resolved: switch cache option to a tri-state option (systemd#5552).
Change the resolved.conf Cache option to a tri-state "no, no-negative, yes" values.
If a lookup returns SERVFAIL systemd-resolved will cache the result for 30s (See 201d995),
however, there are several use cases on which this condition is not acceptable (See systemd#5552 comments)
and the only workaround would be to disable cache entirely or flush it , which isn't optimal.
This change adds the 'no-negative' option when set it avoids putting in cache
negative answers but still works the same heuristics for positive answers.
Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
This commit is contained in:
@@ -41,3 +41,12 @@ bool dns_server_address_valid(int family, const union in_addr_union *sa) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_cache_mode, dns_cache_mode, DnsCacheMode, "Failed to parse DNS cache mode setting")
|
||||
|
||||
static const char* const dns_cache_mode_table[_DNS_CACHE_MODE_MAX] = {
|
||||
[DNS_CACHE_MODE_YES] = "yes",
|
||||
[DNS_CACHE_MODE_NO] = "no",
|
||||
[DNS_CACHE_MODE_NO_NEGATIVE] = "no-negative",
|
||||
};
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dns_cache_mode, DnsCacheMode, DNS_CACHE_MODE_YES);
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
/* 127.0.0.53 in native endian */
|
||||
#define INADDR_DNS_STUB ((in_addr_t) 0x7f000035U)
|
||||
|
||||
typedef enum DnsCacheMode DnsCacheMode;
|
||||
|
||||
enum DnsCacheMode {
|
||||
DNS_CACHE_MODE_NO,
|
||||
DNS_CACHE_MODE_YES,
|
||||
DNS_CACHE_MODE_NO_NEGATIVE,
|
||||
_DNS_CACHE_MODE_MAX,
|
||||
_DNS_CACHE_MODE_INVALID = 1
|
||||
};
|
||||
|
||||
typedef enum ResolveSupport ResolveSupport;
|
||||
typedef enum DnssecMode DnssecMode;
|
||||
typedef enum DnsOverTlsMode DnsOverTlsMode;
|
||||
@@ -56,6 +66,7 @@ enum DnsOverTlsMode {
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_resolve_support);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_mode);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dns_over_tls_mode);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_dns_cache_mode);
|
||||
|
||||
const char* resolve_support_to_string(ResolveSupport p) _const_;
|
||||
ResolveSupport resolve_support_from_string(const char *s) _pure_;
|
||||
@@ -67,3 +78,6 @@ const char* dns_over_tls_mode_to_string(DnsOverTlsMode p) _const_;
|
||||
DnsOverTlsMode dns_over_tls_mode_from_string(const char *s) _pure_;
|
||||
|
||||
bool dns_server_address_valid(int family, const union in_addr_union *sa);
|
||||
|
||||
const char* dns_cache_mode_to_string(DnsCacheMode p) _const_;
|
||||
DnsCacheMode dns_cache_mode_from_string(const char *s) _pure_;
|
||||
|
||||
Reference in New Issue
Block a user