Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/dns/bind9-devel/files/extrapatch-bind-min-override-ttl
16461 views
Add the override-cache-ttl feature.

--- bin/named/config.c.orig	2025-08-13 17:10:38 UTC
+++ bin/named/config.c
@@ -187,6 +187,7 @@ options {\n\
 	notify-source *;\n\
 	notify-source-v6 *;\n\
 	nsec3-test-zone no;\n\
+	override-cache-ttl 0; /* do not override */\n\
 	parental-source *;\n\
 	parental-source-v6 *;\n\
 	provide-ixfr true;\n\
--- bin/named/server.c.orig	2025-08-13 17:10:38 UTC
+++ bin/named/server.c
@@ -4233,6 +4233,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewl
 	}
 
 	obj = NULL;
+	result = named_config_get(maps, "override-cache-ttl", &obj);
+	INSIST(result == ISC_R_SUCCESS);
+	view->overridecachettl = cfg_obj_asduration(obj);
+
+	obj = NULL;
 	result = named_config_get(maps, "max-cache-ttl", &obj);
 	INSIST(result == ISC_R_SUCCESS);
 	view->maxcachettl = cfg_obj_asduration(obj);
--- doc/arm/reference.rst.orig	2025-08-13 17:10:38 UTC
+++ doc/arm/reference.rst
@@ -4187,6 +4187,10 @@ Tuning
    cannot exceed 7 days and is silently truncated to 7 days if set to a
    greater value.
 
+.. namedconf:statement:: override-cache-ttl
+
+   Enforce the configure cache TTL override.
+
 .. namedconf:statement:: max-cache-ttl
    :tags: server
    :short: Specifies the maximum time (in seconds) that the server caches ordinary (positive) answers.
--- doc/misc/options.orig	2025-08-13 17:10:38 UTC
+++ doc/misc/options
@@ -171,6 +171,7 @@ options {
 	masterfile-style ( full | relative );
 	match-mapped-addresses <boolean>;
 	max-cache-size ( default | unlimited | <sizeval> | <percentage> );
+	override-cache-ttl <duration>;
 	max-cache-ttl <duration>;
 	max-clients-per-query <integer>;
 	max-ixfr-ratio ( unlimited | <percentage> );
--- lib/dns/include/dns/view.h.orig	2025-08-13 17:10:38 UTC
+++ lib/dns/include/dns/view.h
@@ -148,6 +148,7 @@ struct dns_view {
 	bool		      requestzoneversion;
 	bool		      sendcookie;
 	dns_ttl_t	      maxcachettl;
+	dns_ttl_t	      overridecachettl;
 	dns_ttl_t	      maxncachettl;
 	dns_ttl_t	      mincachettl;
 	dns_ttl_t	      minncachettl;
--- lib/dns/resolver.c.orig	2025-08-13 17:10:38 UTC
+++ lib/dns/resolver.c
@@ -5766,6 +5766,12 @@ fixttls(dns_view_t *view, dns_rdataset_t *rdataset,
 fixttls(dns_view_t *view, dns_rdataset_t *rdataset,
 	dns_rdataset_t *sigrdataset) {
 	/*
+	 * Enforce the configured cache TTL override.
+	 */
+        if (view->overridecachettl)
+                       rdataset->ttl = view->overridecachettl;
+
+	/*
 	 * Enforce the configured maximum and minimum cache TTL.
 	 */
 	if (rdataset->ttl > view->maxcachettl) {
--- lib/isccfg/namedconf.c.orig	2025-08-13 17:10:38 UTC
+++ lib/isccfg/namedconf.c
@@ -2084,6 +2084,7 @@ static cfg_clausedef_t view_clauses[] = {
 #endif /* ifdef HAVE_LMDB */
 	{ "max-acache-size", NULL, CFG_CLAUSEFLAG_ANCIENT },
 	{ "max-cache-size", &cfg_type_sizeorpercent, 0 },
+	{ "override-cache-ttl", &cfg_type_duration, 0 },
 	{ "max-cache-ttl", &cfg_type_duration, 0 },
 	{ "max-clients-per-query", &cfg_type_uint32, 0 },
 	{ "max-ncache-ttl", &cfg_type_duration, 0 },