From: Tomas Krizek Date: Mon, 15 Nov 2021 16:35:28 +0000 (+0100) Subject: ede: handle stale answers X-Git-Tag: v5.5.0~26^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c81cb1a480f557e34d86abe4618584685da69ea;p=thirdparty%2Fknot-resolver.git ede: handle stale answers --- diff --git a/lib/cache/api.c b/lib/cache/api.c index 0cc61582b..6421c66eb 100644 --- a/lib/cache/api.c +++ b/lib/cache/api.c @@ -237,8 +237,13 @@ int32_t get_new_ttl(const struct entry_h *entry, const struct kr_query *qry, if (res < 0 && owner && qry && qry->stale_cb) { /* Stale-serving decision, delegated to a callback. */ int res_stale = qry->stale_cb(res, owner, type, qry); - if (res_stale >= 0) + if (res_stale >= 0) { + VERBOSE_MSG(qry, "responding with stale answer\n"); + /* LATER: Perhaps we could use a more specific Stale + * NXDOMAIN Answer code for applicable responses. */ + kr_request_set_extended_error(qry->request, KNOT_EDNS_EDE_STALE, NULL); return res_stale; + } } return res; } diff --git a/lib/resolve.c b/lib/resolve.c index 187d7a22a..0e06fb720 100644 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -1629,10 +1629,11 @@ static int ede_priority(int info_code) case KNOT_EDNS_EDE_DS_DIGEST: return 500; /* Non-critical DNSSEC issues */ case KNOT_EDNS_EDE_STALE: + case KNOT_EDNS_EDE_STALE_NXD: + return 300; /* Serve-stale answers. */ case KNOT_EDNS_EDE_INDETERMINATE: case KNOT_EDNS_EDE_CACHED_ERR: case KNOT_EDNS_EDE_NOT_READY: - case KNOT_EDNS_EDE_STALE_NXD: case KNOT_EDNS_EDE_NOTAUTH: case KNOT_EDNS_EDE_NOTSUP: case KNOT_EDNS_EDE_NREACH_AUTH: