1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-28 10:08:24 +00:00
freebsd-ports/dns/bind911/files/extrapatch-bind-min-override-ttl

77 lines
2.5 KiB
Plaintext

- Add the min-cache-ttl config knob.
- Add the override-cache-ttl config knob.
--- bin/named/config.c.orig 2021-05-12 10:45:51 UTC
+++ bin/named/config.c
@@ -182,6 +182,8 @@ options {\n\
" max-acache-size 16M;\n\
max-cache-size 90%;\n\
max-cache-ttl 604800; /* 1 week */\n\
+ min-cache-ttl 0; /* no minimal, zero is allowed */\n\
+ override-cache-ttl 0; /* do not override */\n\
max-clients-per-query 100;\n\
max-ncache-ttl 10800; /* 3 hours */\n\
max-recursion-depth 7;\n\
--- bin/named/server.c.orig 2021-05-12 10:45:51 UTC
+++ bin/named/server.c
@@ -3721,6 +3721,16 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewl
}
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 2021-05-12 10:45:51 UTC
+++ lib/dns/include/dns/view.h
@@ -152,6 +152,8 @@ struct dns_view {
bool requestnsid;
bool sendcookie;
dns_ttl_t maxcachettl;
+ dns_ttl_t mincachettl;
+ dns_ttl_t overridecachettl;
dns_ttl_t maxncachettl;
uint32_t nta_lifetime;
uint32_t nta_recheck;
--- lib/dns/resolver.c.orig 2021-05-12 10:45:51 UTC
+++ lib/dns/resolver.c
@@ -5579,6 +5579,18 @@ cache_name(fetchctx_t *fctx, dns_message_t *rmessage,
}
/*
+ * 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 2021-05-12 10:45:51 UTC
+++ lib/isccfg/namedconf.c
@@ -1773,6 +1773,8 @@ view_clauses[] = {
#endif
{ "max-acache-size", &cfg_type_sizenodefault, 0 },
{ "max-cache-size", &cfg_type_sizeorpercent, 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 },