Skip to content

resolved: add new option to only cache positive answers - #13047

Merged
poettering merged 1 commit into
systemd:masterfrom
niedbalski:fix-5552-pr
Jul 17, 2019
Merged

poettering merged 1 commit into
systemd:masterfrom
niedbalski:fix-5552-pr

Conversation

@niedbalski

@niedbalski niedbalski commented Jul 12, 2019 •

Copy link
Copy Markdown
Contributor

Hello maintainers,

This is a proposal patch to change the resolved.conf Cache option to a tri-state "no, no-negative, yes" values.

If a lookup returns SERVFAIL systemd-resolved will cache the result for 30s (See 201d995),
however, there are several use cases on which this condition is not acceptable (See #5552 comments)
and the only workaround would be to disable cache entirely or flush it , which isn't optimal.

This change adds the 'no-negative' option which when set avoids putting in cache
negative answers but still works the same heuristics for positive answers.

Tests Performed

With this patch applied, No behaves by ignoring all cache types, Yes caches the positive/negative answers and the new option 'no-negative' avoids to cache negative answers.

root@systemd-disco:/home/ubuntu# host www.metaklass.org
Host www.metaklass.org not found: 2(SERVFAIL)

root@systemd-disco:/home/ubuntu# journalctl -u systemd-resolved -n
-- Logs begin at Fri 2019-07-12 18:09:42 UTC, end at Fri 2019-07-12 18:48:31 UTC. --
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Cache miss for www.metaklass.org IN A
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Transaction 22382 for <www.metaklass.org IN A> scope dns on ens3/.
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Using feature level UDP for transaction 22382.
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Sending query packet with id 22382.
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Processing incoming packet on transaction 22382 (rcode=SERVFAIL).
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Server returned error: SERVFAIL
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Not caching negative entry for: www.metaklass.org IN A, cache mode set to no-negative
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Transaction 22382 for <www.metaklass.org IN A> on scope dns on ens3/
now complete with from network (unsigned).
Jul 12 18:48:31 systemd-disco systemd-resolved[2635]: Sending response packet with id 31060 on interface 1/AF_INET.

See #5552

@poettering poettering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks conceptually grace. Two nitpicks

Comment thread src/resolve/resolved-dns-cache.c Resolved
Comment thread src/resolve/resolved-dns-cache.h Resolved
@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Jul 16, 2019
@niedbalski

Copy link
Copy Markdown
Contributor Author

@poettering Thank you for your review. I've amended your observations, Thanks.

@keszybz keszybz changed the title resolved: switch cache option to a tri-state option (systemd#5552). resolved: switch cache option to a tri-state option Jul 17, 2019
@keszybz keszybz removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Jul 17, 2019

@keszybz keszybz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks nice, but the docs need one more round.

Comment thread man/resolved.conf.xml Resolved
Comment thread man/resolved.conf.xml Resolved
Comment thread src/resolve/resolved-conf.h Resolved
Comment thread src/resolve/resolved-dns-cache.c Resolved
@keszybz keszybz added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Jul 17, 2019
@keszybz keszybz changed the title resolved: switch cache option to a tri-state option resolved: add new option to only cache positive answers Jul 17, 2019
Comment thread src/resolve/resolved-dns-cache.h Resolved
Comment thread NEWS Resolved
@niedbalski
niedbalski force-pushed the fix-5552-pr branch 3 times, most recently from f34c236 to cbf43f8 Compare July 17, 2019 14:31
Change the resolved.conf Cache option to a tri-state "no, no-negative, yes" values.

If a lookup returns SERVFAIL systemd-resolved will cache the result for 30s (See 201d995),
however, there are several use cases on which this condition is not acceptable (See systemd#5552 comments)
and the only workaround would be to disable cache entirely or flush it , which isn't optimal.

This change adds the 'no-negative' option when set it avoids putting in cache
negative answers but still works the same heuristics for positive answers.

Signed-off-by: Jorge Niedbalski <[email protected]>
@niedbalski

Copy link
Copy Markdown
Contributor Author

@keszybz @poettering Thank you for your review and time spent on this. I've amended the requested changes and observations and It's ready for your review.

@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jul 17, 2019
@keszybz

keszybz commented Jul 17, 2019

Copy link
Copy Markdown
Member

LGTM.

@poettering
poettering merged commit ea582a0 into systemd:master Jul 17, 2019
@keszybz keszybz removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Oct 21, 2026
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.

4 participants