summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2020-07-22 13:25:51 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2023-06-12 10:22:45 +0200
commitc19ff9fa667a935e669058cee3e45a7c8f48ac81 (patch)
treedc324af8a64de2c60e9b283a7ed631849de13c08
parentlib/cache: simplify passing qry/req parameters (diff)
downloadknot-resolver-c19ff9fa667a935e669058cee3e45a7c8f48ac81.tar.xz
knot-resolver-c19ff9fa667a935e669058cee3e45a7c8f48ac81.zip
lib/cache pkt_append(): drop unnecessary argument
We already had rank stored in there, in particular entry2answer() always stored it.
-rw-r--r--lib/cache/impl.h4
-rw-r--r--lib/cache/knot_pkt.c4
-rw-r--r--lib/cache/peek.c9
3 files changed, 9 insertions, 8 deletions
diff --git a/lib/cache/impl.h b/lib/cache/impl.h
index e25d13fe..d650e379 100644
--- a/lib/cache/impl.h
+++ b/lib/cache/impl.h
@@ -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);
diff --git a/lib/cache/knot_pkt.c b/lib/cache/knot_pkt.c
index 864cb57c..4b28891e 100644
--- a/lib/cache/knot_pkt.c
+++ b/lib/cache/knot_pkt.c
@@ -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;
diff --git a/lib/cache/peek.c b/lib/cache/peek.c
index 5db1fbc8..719652aa 100644
--- a/lib/cache/peek.c
+++ b/lib/cache/peek.c
@@ -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. */