Skip to content

Commit

Permalink
daemon: always refetch CNAME target in 'strict' mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vavrusa committed Jul 18, 2016
1 parent 7065665 commit 41dbede
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/layer/iterate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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) {
Expand All @@ -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 */
Expand Down

0 comments on commit 41dbede

Please sign in to comment.