From 441e41382b97c7ff8802a2ed78f4ca6a0c672489 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 9 Jan 2012 16:08:42 -0800 Subject: [PATCH] dnsproxy: Have a minimum cache TTL some DNS servers return an extremely short TTL causing all kinds of fun. This patch ensures that we just enforce a minimum TTL of 30 seconds. --- src/dnsproxy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dnsproxy.c b/src/dnsproxy.c index c373ae1..a30f4c4 100644 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -160,6 +160,10 @@ struct domain_rr { * when setting the cache entry life time. The value is in seconds. */ #define MAX_CACHE_TTL (60 * 30) +/* + * Also limit the other end, cache at least for 30 seconds. + */ +#define MIN_CACHE_TTL (30) /* * We limit the cache size to some sane value so that cached data does @@ -1136,6 +1140,9 @@ static int cache_update(struct server_data *srv, unsigned char *msg, new_entry = FALSE; } + if (ttl < MIN_CACHE_TTL) + ttl = MIN_CACHE_TTL; + data->inserted = current_time; data->type = type; data->answers = answers; -- 2.7.4