Commit 4e766ef0 authored by Marek Vavrusa's avatar Marek Vavrusa

daemon: always refetch CNAME target in 'strict' mode

in normal mode, only final CNAME target is refetched, but
not intermediate CNAMEs. intermediate CNAMEs are *never* cached,
but they are used to get final name for requery. in strict mode now,
every CNAME target is explicitly fetched even if it's a chained CNAME.
parent 736ba7c7
......@@ -396,6 +396,7 @@ static int process_answer(knot_pkt_t *pkt, struct kr_request *req)
const knot_dname_t *pending_cname = query->sname;
unsigned cname_chain_len = 0;
bool can_follow = false;
bool strict_mode = (query->flags & QUERY_STRICT);
do {
/* CNAME was found at previous iteration, but records may not follow the correct order.
* Try to find records for pending_cname owner from section start. */
......@@ -429,7 +430,7 @@ static int process_answer(knot_pkt_t *pkt, struct kr_request *req)
}
cname_chain_len += 1;
pending_cname = knot_cname_name(&rr->rrs);
if (!pending_cname) {
if (!pending_cname || strict_mode) {
break;
}
if (cname_chain_len > an->count || cname_chain_len > KR_CNAME_CHAIN_LIMIT) {
......@@ -439,6 +440,11 @@ static int process_answer(knot_pkt_t *pkt, struct kr_request *req)
/* Don't use pending_cname immediately.
* There are can be records for "old" cname. */
}
/* In strict mode, explicitly fetch each CNAME target. */
if (strict_mode && pending_cname) {
cname = pending_cname;
break;
}
} while (pending_cname && can_follow);
/* Make sure that this is an authoritative answer (even with AA=0) for other layers */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment