Skip to content

resolve: do not hit CNAME or DNAME entry in NODATA cache - #9836

Merged
yuwata merged 1 commit into
systemd:masterfrom
yuwata:fix-9833
Aug 13, 2018
Merged

yuwata merged 1 commit into
systemd:masterfrom
yuwata:fix-9833

Conversation

@yuwata

@yuwata yuwata commented Aug 9, 2018

Copy link
Copy Markdown
Member

Fixes #9833.

Though, I am not sure this is a right way to fix the problem...

@filbranden

Copy link
Copy Markdown
Contributor

Though, I am not sure this is a right way to fix the problem...

I don't know, fixing this at time of lookup looks odd to me too...

I didn't have too much time to look into this (or test this), but I noticed that:

Line 705 above, in dns_cache_put(), has:

         /* But not if it has a matching CNAME/DNAME (the negative
          * caching will be done on the canonical name, not on the
          * alias) */
         r = dns_answer_find_cname_or_dname(answer, key, NULL, NULL);
         if (r < 0)
                 goto fail;
         if (r > 0)
                 return 0;

Perhaps a fix somewhere around there would be more appropriate?

I don't know if maybe the problem is whether the code currently can't distinguish between CNAME returning NODATA (which seems to be what the opened issue is triggering) and CNAME getting resolved, but the canonical name later returning NODATA (which seems to be what systemd is currently handling...)

@yuwata

yuwata commented Aug 11, 2018

Copy link
Copy Markdown
Member Author

I may not correctly understand your comments or the comment in the source you referred. But I think storing the result into NODATA cache seems not bad. But using the cache entry for different type of question is not good and causes the issue.

I mean that when we callresolvectl query -t CNAME google.com multiple times, then the NODATA cache entry is very useful. So, I judge that the cache entry itself does not have any problems.

@filbranden filbranden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

I was assuming that the problem was when adding entries to the cache, but that's not the case, the code will correctly add <domain, CNAME, NODATA> to the cache, but while looking it up, this function was indeed skipping other lookups because of this entry. The patch as proposed fixes this.

I also confirmed that the CNAME negative cache is working as expected, doing two lookups for CNAME on an entry that isn't a CNAME, the second one will come from the cache.

So as far as I can tell, this works as expected. I couldn't come up with any case where this would break anything or not really work as expected.

Thanks!
Filipe

@yuwata
yuwata merged commit 3740146 into systemd:master Aug 13, 2018
@yuwata
yuwata deleted the fix-9833 branch August 13, 2018 05:32
fpletz pushed a commit to NixOS/systemd that referenced this pull request Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Cached cname NODATA returned for A lookup

2 participants