]> git.ipfire.org Git - thirdparty/squid.git/commit
Honor DNS RR TTLs larger than negative_dns_ttl (#1380)
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 19 Jun 2023 01:48:38 +0000 (01:48 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 19 Jun 2023 18:27:51 +0000 (18:27 +0000)
commiteae95059eb61ecedafd695d676432246c44f88ae
tree56f4440a1009effbaf7c92866b4b5447869d2c1c
parentd743956a070cbba4757e2e91991017e51095397b
Honor DNS RR TTLs larger than negative_dns_ttl (#1380)

Since 2017 commit fd9c47d, Squid was effectively ignoring DNS RR TTLs
that exceeded negative_dns_ttl (i.e. 60 seconds by default) because the
"find the smallest TTL across the DNS records seen so far" code in
ipcache_entry::updateTtl() mistook the "default" ipcache_entry::expires
value as the one based on an earlier seen DNS record.

In most cases, this bug decreased IP cache hit ratio.

Existing fqdncache code does not suffer from the same bug because
fqdncacheParse() always resets fqdncache_entry::expires instead of
updating it incrementally. ipcacheParse() has to update incrementally
because it is called twice per entry, once with an A answer and once
with an AAAA answer.

Ideally, ipcache_entry::expires should be made optional to eliminate
awkward "first updateTtl() call" detection, but doing so well requires
significant code changes, so that entries without a known expiration
value are not cached forever _unless_ they were loaded from /etc/hosts.
And those changes should probably be propagated to fqdncache.cc.
src/ipcache.cc