]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/utils kr_ranked_rrarray_add(): clarify RRset sizes
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 17 May 2021 11:05:02 +0000 (13:05 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 25 May 2021 12:39:45 +0000 (14:39 +0200)
lib/cache/impl.h
lib/utils.c

index ef07b828f00aa0c7c43489de42b5fd06d4fa8fdf..4b934a88a5d9701b532aba2186ca8455eb824584 100644 (file)
@@ -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);
 
index 7287fcfe48fc6787c80a14cf5fe2cd74dcac031d..1812082ffc76dc594ffa7325ddd02ce6d7f05478 100644 (file)
@@ -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),