summaryrefslogtreecommitdiffstats
path: root/dns/bind9-devel/files/extrapatch-bind-min-override-ttl
blob: a28843d6b60c2889925b8fdf390d4179533fbb9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--- bin/named/config.c.orig	2017-06-14 01:08:21 UTC
+++ bin/named/config.c
@@ -155,6 +155,8 @@ options {\n\
 	lame-ttl 600;\n\
 	servfail-ttl 1;\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 90%;\n\
--- bin/named/server.c.orig	2017-06-14 01:08:21 UTC
+++ bin/named/server.c
@@ -3713,6 +3713,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-06-14 01:08:21 UTC
+++ lib/dns/include/dns/view.h
@@ -143,6 +143,8 @@ struct dns_view {
 	isc_boolean_t			requestnsid;
 	isc_boolean_t			sendcookie;
 	dns_ttl_t			maxcachettl;
+	dns_ttl_t			mincachettl;
+	dns_ttl_t			overridecachettl;
 	dns_ttl_t			maxncachettl;
 	isc_uint32_t			nta_lifetime;
 	isc_uint32_t			nta_recheck;
--- lib/dns/resolver.c.orig	2017-06-14 01:08:21 UTC
+++ lib/dns/resolver.c
@@ -5468,6 +5468,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-06-14 01:08:21 UTC
+++ lib/isccfg/namedconf.c
@@ -1893,6 +1893,8 @@ view_clauses[] = {
 	{ "max-acache-size", &cfg_type_sizenodefault,
 	  CFG_CLAUSEFLAG_OBSOLETE },
 	{ "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 },
OpenPOWER on IntegriCloud