diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 3b6e8d7d65..c923d7c6e5 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -143,6 +143,7 @@ EXTERN bool named_g_memstatistics INIT(false); EXTERN bool named_g_keepstderr INIT(false); EXTERN unsigned int named_g_tat_interval INIT(24 * 3600); +EXTERN unsigned int named_g_maxcachesize INIT(0); #if defined(HAVE_GEOIP2) EXTERN dns_geoip_databases_t *named_g_geoip INIT(NULL); diff --git a/bin/named/main.c b/bin/named/main.c index b369eed069..d6b7154246 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -650,6 +650,8 @@ parse_T_opt(char *option) { named_g_nosyslog = true; } else if (!strcmp(option, "notcp")) { notcp = true; + } else if (!strncmp(option, "maxcachesize=", 13)) { + named_g_maxcachesize = atoi(option + 13); } else if (!strcmp(option, "maxudp512")) { maxudp = 512; } else if (!strcmp(option, "maxudp1460")) { diff --git a/bin/named/server.c b/bin/named/server.c index 547df1147a..ec66cbcc9e 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4114,7 +4114,16 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, obj = NULL; result = named_config_get(maps, "max-cache-size", &obj); INSIST(result == ISC_R_SUCCESS); - if (cfg_obj_isstring(obj)) { + /* + * If "-T maxcachesize=..." is in effect, it overrides any other + * "max-cache-size" setting found in configuration, either implicit or + * explicit. For simplicity, the value passed to that command line + * option is always treated as the number of bytes to set + * "max-cache-size" to. + */ + if (named_g_maxcachesize != 0) { + max_cache_size = named_g_maxcachesize; + } else if (cfg_obj_isstring(obj)) { str = cfg_obj_asstring(obj); INSIST(strcasecmp(str, "unlimited") == 0); max_cache_size = 0;