]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Fix the wrong RD and CD flags being cached, causing misses
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 16 Aug 2021 10:51:15 +0000 (12:51 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 16 Aug 2021 10:51:15 +0000 (12:51 +0200)
commitdbadb4d272a3317407e6bc934f55c2d41a87c0ac
tree6cdb8952b3645957051ed13157b47237f81d4e7a
parentbc63770e08717cf29e0609c2ed086d97da142597
dnsdist: Fix the wrong RD and CD flags being cached, causing misses

We used to restore the RD and CD flags from the initial query before
inserting the response into the cache. That would cause an issue
if the flags had been altered, for example via SetNoRecurseAction,
as the cache lookup is done _after_ the actions have been applied
and thus after the flags altered.
If the initial query had the RD bit set, and thus was cleared by the
rule, the response would have been inserted with the RD bit restored,
and no lookup would then succeed because it would be done with the
bit cleared.
This commit fixes the insertion to use the RD and CD bits as set in
the response before restoring them, and restores the RD and CD bits
after a cache hit as well, to ensure that:
- cache lookups are done after the rules are applied
- cache insertions are done before the flags are restored
pdns/dnsdist.cc
regression-tests.dnsdist/test_Caching.py