Discussion:
[Dnsmasq-discuss] Cache is flushed repeated when 2 cname point to the same domain
石磊
2017-01-09 01:43:13 UTC
Permalink
Hi,

We are running into an issue that the cache is flushed repeated when 2 cnames are point to the same domain. For example,
Domain-A is cnamed to Domain-True
Domain-B is cnamed to Domain-True, and then Domain-True is a A record.
In this configuration, if we dig in the sequence: Domain-A=> Domain-B=> Domain-A=> Domain-B,
we saw the 3rd step and 4th step are forwarded.

After read the code, we found in the function ¡°cache_scan_free¡±, it will check the A record, and remove it if found. My question is it seems not necessary to do this check to do this check? Since only when the cache missing or expire or cache full will trigger a forward, correct me if I am worng or miss anything.

Thanks!
Simon Kelley
2017-01-10 17:46:09 UTC
Permalink
Post by 石磊
Hi,
We are running into an issue that the cache is flushed repeated
when 2 cnames are point to the same domain. For example, Domain-A
is cnamed to Domain-True Domain-B is cnamed to Domain-True, and
then Domain-True is a A record. In this configuration, if we dig in
the sequence: Domain-A=> Domain-B=> Domain-A=> Domain-B, we saw the
3rd step and 4th step are forwarded.
After read the code, we found in the function “cache_scan_free”,
it will check the A record, and remove it if found. My question is
it seems not necessary to do this check to do this check? Since
only when the cache missing or expire or cache full will trigger a
forward, correct me if I am worng or miss anything.
This is an unfortunate side-effect of the way that the cache is
implemented. CNAMEs are stored as a pointer to a second cached entry
representing another CNAME or a A (or AAAA) record, and not as CNAMES
to a name. THis has advantages (cache entries always contain exactly
one variable length name, and the targets of CNAMES are found "for
free". But it does have the disadvantage that the cache can't
represent the condition you have, two different CNAMES to the same
target. The results of queries are never incorrect, but caching
behavior may not be optimal.

A work around, I think, would be to make Domain-A a CNAME to Domain-B
and Domains-B a CNAME to Domain-true.

Cheers,

Simon.

Loading...