diff options
author | Petr Špaček <petr.spacek@nic.cz> | 2017-04-18 16:07:48 +0200 |
---|---|---|
committer | Petr Špaček <petr.spacek@nic.cz> | 2017-04-18 16:07:48 +0200 |
commit | 7517d5dab4c35095bbd1346160f99d0db1bc93bf (patch) | |
tree | a1aa0001b5b1166440133885bca3a8360514c583 | |
parent | Merge branch 'fix-oo-wc-nodata' into 'master' (diff) | |
parent | rrcache: don't clobber pkt if failing the second step (diff) | |
download | knot-resolver-7517d5dab4c35095bbd1346160f99d0db1bc93bf.tar.xz knot-resolver-7517d5dab4c35095bbd1346160f99d0db1bc93bf.zip |
Merge branch 'rrcache-pkt-clobber' into 'master'
rrcache: don't clobber pkt if failing the second step
See merge request !274
-rw-r--r-- | lib/layer/rrcache.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/layer/rrcache.c b/lib/layer/rrcache.c index e7f3a0f8..d5d908a3 100644 --- a/lib/layer/rrcache.c +++ b/lib/layer/rrcache.c @@ -117,6 +117,21 @@ static int loot_rrcache(struct kr_cache *cache, knot_pkt_t *pkt, } else if (ret == 0 && dobit) { ret = loot_rr(cache, pkt, qry->sname, qry->sclass, rrtype, qry, &rank, &flags, true, lowest_rank); + if (ret) { + VERBOSE_MSG(qry, "=> RRSIG(s) expected but not found, skipping"); + /* In some cases, e.g. due to bugs, this may fail. + * A possible good example is that a cache backend + * (such as redis) chose to evict RRSIG but not RRset. + * Let's return cache failure, but the packet has been + * updated already by the RRs! Let's try to clear it. + * The following command might theoretically fail again + * while parsing question, but let's just log that + * condition in non-debug mode (it might be non-fatal). */ + if (kr_pkt_clear_payload(pkt)) { + kr_log_error("[ rc ] => ERROR: work-around failed\n"); + assert(false); + } + } } return ret; } @@ -411,7 +426,7 @@ static int rrcache_stash(kr_layer_t *ctx, knot_pkt_t *pkt) if (ret == kr_error(ENOSPC)) { ret = kr_cache_clear(cache); if (ret != 0 && ret != kr_error(EEXIST)) { - kr_log_error("[cache] failed to clear cache: %s\n", kr_strerror(ret)); + kr_log_error("[ rc ] failed to clear cache: %s\n", kr_strerror(ret)); } } kr_cache_sync(cache); |