Commit 8e2716f8 authored by Grigorii Demidov's avatar Grigorii Demidov

Merge branch 'fix-dups' into 'master'

layer/validate: fix duplicate records in AUTHORITY section in case of WC expansion proof

See merge request !216
parents 9574949f 47e8bb34
......@@ -710,7 +710,7 @@ static int validate(kr_layer_t *ctx, knot_pkt_t *pkt)
/* Check if wildcard expansion detected for final query.
* If yes, copy authority. */
if ((qry->parent == NULL) && (qry->flags & QUERY_DNSSEC_WEXPAND)) {
kr_ranked_rrarray_set_wire(&req->auth_selected, true, qry->uid);
kr_ranked_rrarray_set_wire(&req->auth_selected, true, qry->uid, true);
}
/* Check and update current delegation point security status. */
......
......@@ -493,12 +493,33 @@ int kr_ranked_rrarray_add(ranked_rr_array_t *array, const knot_rrset_t *rr,
return kr_ok();
}
int kr_ranked_rrarray_set_wire(ranked_rr_array_t *array, bool to_wire, uint32_t qry_uid)
int kr_ranked_rrarray_set_wire(ranked_rr_array_t *array, bool to_wire,
uint32_t qry_uid, bool check_dups)
{
for (size_t i = 0; i < array->len; ++i) {
ranked_rr_array_entry_t *entry = array->at[i];
if (entry->qry_uid == qry_uid) {
entry->to_wire = to_wire;
if (entry->qry_uid != qry_uid) {
continue;
}
entry->to_wire = to_wire;
if (!to_wire || !check_dups) {
continue;
}
knot_rrset_t *rr = entry->rr;
for (size_t j = 0; j < array->len; ++j) {
ranked_rr_array_entry_t *stashed = array->at[j];
if (stashed->qry_uid == qry_uid) {
continue;
}
if (stashed->rr->rclass != rr->rclass ||
stashed->rr->type != rr->type) {
continue;
}
bool is_equal = knot_rrset_equal(rr, stashed->rr,
KNOT_RRSET_COMPARE_WHOLE);
if (is_equal) {
stashed->to_wire = false;
}
}
}
return kr_ok();
......
......@@ -193,7 +193,16 @@ int kr_rrarray_add(rr_array_t *array, const knot_rrset_t *rr, knot_mm_t *pool);
int kr_ranked_rrarray_add(ranked_rr_array_t *array, const knot_rrset_t *rr,
uint8_t rank, bool to_wire, uint32_t qry_uid, knot_mm_t *pool);
int kr_ranked_rrarray_set_wire(ranked_rr_array_t *array, bool to_wire, uint32_t qry_uid);
/** @internal Mark the RRSets from particular query as
* "have (not) to be recorded in the final answer".
* @param array RRSet array.
* @param to_wire Records must be\must not be recorded in final answer.
* @param qry_uid Query uid.
* @param check_dups When to_wire is true, try to avoid duplicate RRSets.
* @return 0 or an error
*/
int kr_ranked_rrarray_set_wire(ranked_rr_array_t *array, bool to_wire,
uint32_t qry_uid, bool check_dups);
void kr_rrset_print(const knot_rrset_t *rr, const char *prefix);
void kr_pkt_print(knot_pkt_t *pkt);
......
Subproject commit 23123278300caac55c0cccfeccc96267246b0993
Subproject commit b7453577c57cb837261ca6e21098b8a44a9e8b3d
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