barrucadu / resolved

A simple DNS server for home networks.
https://resolved.docs.barrucadu.co.uk/
21 stars 0 forks source link

Recursive resolution will not work if intermediate records cannot be cached #12

Open barrucadu opened 2 years ago

barrucadu commented 2 years ago

RFC 1035 says:

Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.

Currently the only way intermediary RRs get used is by sticking them in the cache. So if an essential record has a TTL of zero, resolved will fail to make use of it: it will look up that record every time it needs it, and I wouldn't be surprised if this could cause an infinite loop in some cases.

I think the way to solve this is to have an additional transaction-local cache inside the SharedCache, which only stores RRs with a TTL of zero.

barrucadu commented 2 years ago

This isn't just a problem with 0-TTL records. If resolving a record requires more records to be cached than the cache can hold, it will get stuck in a loop.

So we do need a sort of request-local cache, in addition to the shared cache. The request-local cache would hold everything, with inserts pushing records of TTL > 0 into the shared cache.