return newttl < 0 ? kr_error(ESTALE) : kr_ok();
}
-static uint8_t get_lowest_rank(const struct kr_request *req, const struct kr_query *qry)
+static uint8_t get_lowest_rank(const struct kr_query *qry, const knot_dname_t *name, const uint16_t type)
{
/* TODO: move rank handling into the iterator (DNSSEC_* flags)? */
const bool allow_unverified =
- knot_wire_get_cd(req->qsource.packet->wire) || qry->flags.STUB;
+ knot_wire_get_cd(qry->request->qsource.packet->wire) || qry->flags.STUB;
/* in stub mode we don't trust RRs anyway ^^ */
if (qry->flags.NONAUTH) {
return KR_RANK_INITIAL;
} else if (!allow_unverified) {
/* Records not present under any TA don't have their security
* verified at all, so we also accept low ranks in that case. */
- const bool ta_covers = kr_ta_covers_qry(req->ctx, qry->sname, qry->stype);
+ const bool ta_covers = kr_ta_covers_qry(qry->request->ctx, name, type);
/* ^ TODO: performance? TODO: stype - call sites */
if (ta_covers) {
return KR_RANK_INSECURE | KR_RANK_AUTH;
return ctx->state;
}
- const uint8_t lowest_rank = get_lowest_rank(req, qry);
+ const uint8_t lowest_rank = get_lowest_rank(qry, qry->sname, qry->stype);
/**** 1. find the name or the closest (available) zone, not considering wildcards
**** 1a. exact name+type match (can be negative, mainly in insecure zones) */
return kr_error(EILSEQ);
}
const int32_t log_new_ttl = get_new_ttl(eh, qry, k->zname, type, timestamp);
- const uint8_t rank_min = KR_RANK_INSECURE | KR_RANK_AUTH;
- const bool ok = /* For NS any kr_rank is accepted,
- * as insecure or even nonauth is OK */
- (type == KNOT_RRTYPE_NS || eh->rank >= rank_min)
- /* Not interested in negative bogus or outdated RRs. */
- && !eh->is_packet && log_new_ttl >= 0;
+
+ const bool ok = /* Not interested in negative bogus or outdated RRs. */
+ !eh->is_packet && log_new_ttl >= 0
+ /* For NS any kr_rank is accepted, as insecure or even nonauth is OK */
+ && (type == KNOT_RRTYPE_NS
+ || eh->rank >= get_lowest_rank(qry, k->zname, type));
+
WITH_VERBOSE(qry) { if (!ok) {
auto_free char *type_str = kr_rrtype_text(type);
const char *packet_str = eh->is_packet ? "packet" : "RR";