--- bin/named/config.c.orig 2017-04-14 03:54:11 UTC +++ bin/named/config.c @@ -154,6 +154,8 @@ options {\n\ min-roots 2;\n\ lame-ttl 600;\n\ max-ncache-ttl 10800; /* 3 hours */\n\ + override-cache-ttl 0; /* do not override */\n\ + min-cache-ttl 0; /* no minimal, zero is allowed */\n\ max-cache-ttl 604800; /* 1 week */\n\ transfer-format many-answers;\n\ max-cache-size 0;\n\ --- bin/named/server.c.orig 2017-04-14 03:54:11 UTC +++ bin/named/server.c @@ -2890,6 +2890,16 @@ configure_view(dns_view_t *view, dns_vie } obj = NULL; + result = ns_config_get(maps, "override-cache-ttl", &obj); + INSIST(result == ISC_R_SUCCESS); + view->overridecachettl = cfg_obj_asuint32(obj); + + obj = NULL; + result = ns_config_get(maps, "min-cache-ttl", &obj); + INSIST(result == ISC_R_SUCCESS); + view->mincachettl = cfg_obj_asuint32(obj); + + obj = NULL; result = ns_config_get(maps, "max-cache-ttl", &obj); INSIST(result == ISC_R_SUCCESS); view->maxcachettl = cfg_obj_asuint32(obj); --- lib/dns/include/dns/view.h.orig 2017-04-14 03:54:11 UTC +++ lib/dns/include/dns/view.h @@ -151,6 +151,8 @@ struct dns_view { isc_boolean_t requestnsid; isc_boolean_t requestsit; dns_ttl_t maxcachettl; + dns_ttl_t mincachettl; + dns_ttl_t overridecachettl; dns_ttl_t maxncachettl; dns_ttl_t prefetch_trigger; dns_ttl_t prefetch_eligible; --- lib/dns/resolver.c.orig 2017-04-14 03:54:11 UTC +++ lib/dns/resolver.c @@ -5378,6 +5378,18 @@ cache_name(fetchctx_t *fctx, dns_name_t } /* + * Enforce the configure cache TTL override. + */ + if (res->view->overridecachettl) + rdataset->ttl = res->view->overridecachettl; + + /* + * Enforce the configure minimum cache TTL. + */ + if (rdataset->ttl < res->view->mincachettl) + rdataset->ttl = res->view->mincachettl; + + /* * Enforce the configure maximum cache TTL. */ if (rdataset->ttl > res->view->maxcachettl) --- lib/isccfg/namedconf.c.orig 2017-04-14 03:54:11 UTC +++ lib/isccfg/namedconf.c @@ -1591,6 +1591,8 @@ view_clauses[] = { #endif { "max-acache-size", &cfg_type_sizenodefault, 0 }, { "max-cache-size", &cfg_type_sizenodefault, 0 }, + { "override-cache-ttl", &cfg_type_uint32, 0 }, + { "min-cache-ttl", &cfg_type_uint32, 0 }, { "max-cache-ttl", &cfg_type_uint32, 0 }, { "max-clients-per-query", &cfg_type_uint32, 0 }, { "max-ncache-ttl", &cfg_type_uint32, 0 },