From: Vladimír Čunát Date: Mon, 17 May 2021 11:05:02 +0000 (+0200) Subject: lib/utils kr_ranked_rrarray_add(): clarify RRset sizes X-Git-Tag: v5.4.0~18^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6466ed1ef24d65478a56d966497113fc90eeca8;p=thirdparty%2Fknot-resolver.git lib/utils kr_ranked_rrarray_add(): clarify RRset sizes --- diff --git a/lib/cache/impl.h b/lib/cache/impl.h index ef07b828f..4b934a88a 100644 --- a/lib/cache/impl.h +++ b/lib/cache/impl.h @@ -355,9 +355,12 @@ int entry2answer(struct answer *ans, int id, int pkt_renew(knot_pkt_t *pkt, const knot_dname_t *name, uint16_t type); /** Append RRset + its RRSIGs into the current section (*shallow* copy), with given rank. + * * \note it works with empty set as well (skipped) * \note pkt->wire is not updated in any way * \note KNOT_CLASS_IN is assumed + * \note Whole RRsets are put into the pseudo-packet; + * normal parsed packets would only contain single-RR sets. */ int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset, uint8_t rank); diff --git a/lib/utils.c b/lib/utils.c index 7287fcfe4..1812082ff 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -706,8 +706,10 @@ typedef array_t(knot_rdata_t *) rdata_array_t; 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) { - /* rr always has one record per rrset - * check if another rrset with the same + /* From normal packet parser we always get RRs one by one, + * but cache and prefil modules (also) feed us larger RRsets. */ + (void)!kr_assume(rr->rrs.count >= 1); + /* Check if another rrset with the same * rclass/type/owner combination exists within current query * and merge if needed */ for (ssize_t i = array->len - 1; i >= 0; --i) { @@ -727,8 +729,6 @@ int kr_ranked_rrarray_add(ranked_rr_array_t *array, const knot_rrset_t *rr, /* Found the entry to merge with. Check consistency and merge. */ if (!kr_assume(stashed->rank == rank && !stashed->cached && stashed->in_progress)) return kr_error(EEXIST); - //(void)!kr_assume(rr->rrs.count == 1); - /* ^^ shouldn't be a problem for this function, but it's probably a bug */ /* It may happen that an RRset is first considered useful * (to_wire = false, e.g. due to being part of glue),