]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache pkt_append(): drop unnecessary argument
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 22 Jul 2020 11:25:51 +0000 (13:25 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 12 Jun 2023 08:22:45 +0000 (10:22 +0200)
We already had rank stored in there, in particular
entry2answer() always stored it.

lib/cache/impl.h
lib/cache/knot_pkt.c
lib/cache/peek.c

index e25d13fe6de33d339c6588db0f981f164f976120..d650e379fc5fb5986572cbba7e6253f76d1ac326 100644 (file)
@@ -362,7 +362,7 @@ int entry2answer(struct answer *ans, int id,
 /** Prepare answer packet to be filled by RRs (without RR data in wire). */
 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.
+/** Append RRset + its RRSIGs into the current section (*shallow* copy).
  *
  * \note it works with empty set as well (skipped)
  * \note pkt->wire is not updated in any way
@@ -370,7 +370,7 @@ int pkt_renew(knot_pkt_t *pkt, const knot_dname_t *name, uint16_t type);
  * \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);
+int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset);
 
 
 
index 864cb57ca9e32150e082cc3cdbd88be378fe30fb..4b28891e979acc8ad55188a6fe4b0f4d3fa1e47c 100644 (file)
@@ -55,7 +55,7 @@ static int pkt_alloc_space(knot_pkt_t *pkt, int count)
        return kr_ok();
 }
 
-int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset, uint8_t rank)
+int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset)
 {
        /* allocate space, to be sure */
        int rrset_cnt = (rrset->set.rr->rrs.count > 0) + (rrset->sig_rds.count > 0);
@@ -69,7 +69,7 @@ int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset, uint8_t rank)
                /* allocate rank */
                uint8_t *rr_rank = mm_alloc(&pkt->mm, sizeof(*rr_rank));
                if (!rr_rank) return kr_error(ENOMEM);
-               *rr_rank = (i == 0) ? rank : (KR_RANK_OMIT | KR_RANK_AUTH);
+               *rr_rank = (i == 0) ? rrset->set.rank : (KR_RANK_OMIT | KR_RANK_AUTH);
                        /* rank for RRSIGs isn't really useful: ^^ */
                if (i == 0) {
                        pkt->rr[pkt->rrset_count] = *rrset->set.rr;
index 5db1fbc822f15ae994b25d596a52ed6235516131..719652aa9929f2e8b7a892694b318b498bcda747 100644 (file)
@@ -304,7 +304,7 @@ int peek_nosync(kr_layer_t *ctx, knot_pkt_t *pkt)
                if (i == 1) knot_pkt_begin(pkt, KNOT_AUTHORITY);
                if (!ans.rrsets[i].set.rr) continue;
                expiring = expiring || ans.rrsets[i].set.expiring;
-               ret = pkt_append(pkt, &ans.rrsets[i], ans.rrsets[i].set.rank);
+               ret = pkt_append(pkt, &ans.rrsets[i]);
                if (kr_fails_assert(ret == 0))
                        return ctx->state;
        }
@@ -437,7 +437,7 @@ static int answer_simple_hit(struct kr_query *qry, knot_pkt_t *pkt, uint16_t typ
                           qry->sname, type, new_ttl);
        CHECK_RET(ret);
        /* Put links to the materialized data into the pkt. */
-       ret = pkt_append(pkt, &ans.rrsets[AR_ANSWER], eh->rank);
+       ret = pkt_append(pkt, &ans.rrsets[AR_ANSWER]);
        CHECK_RET(ret);
 
        answer_simple_qflags(&qry->flags, eh, new_ttl);
@@ -463,13 +463,14 @@ static int answer_dname_hit(struct kr_query *qry, knot_pkt_t *pkt, const knot_dn
                           dname_owner, KNOT_RRTYPE_DNAME, new_ttl);
        CHECK_RET(ret);
        /* Put link to the RRset into the pkt. */
-       ret = pkt_append(pkt, &ans.rrsets[AR_ANSWER], eh->rank);
+       ret = pkt_append(pkt, &ans.rrsets[AR_ANSWER]);
        CHECK_RET(ret);
        const knot_dname_t *dname_target =
                knot_dname_target(ans.rrsets[AR_ANSWER].set.rr->rrs.rdata);
 
        /* Generate CNAME RRset for the answer in (pseudo-)packet. */
        const int AR_CNAME = AR_SOA;
+       ans.rrsets[AR_CNAME].set.rank = ans.rrsets[AR_ANSWER].set.rank;
        knot_rrset_t *rr = ans.rrsets[AR_CNAME].set.rr
                = knot_rrset_new(qry->sname, KNOT_RRTYPE_CNAME, KNOT_CLASS_IN,
                                 new_ttl, ans.mm);
@@ -488,7 +489,7 @@ static int answer_dname_hit(struct kr_query *qry, knot_pkt_t *pkt, const knot_dn
                CHECK_RET(rr->rrs.rdata ? kr_ok() : -ENOMEM);
                knot_rdata_init(rr->rrs.rdata, rdata_len, cname_target);
                /* Put link to the RRset into the pkt. */
-               ret = pkt_append(pkt, &ans.rrsets[AR_CNAME], eh->rank);
+               ret = pkt_append(pkt, &ans.rrsets[AR_CNAME]);
                CHECK_RET(ret);
        } else {
                /* Note that it's basically a successful answer; name just doesn't fit. */