Skip to content
Snippets Groups Projects
Commit 7c47ead6 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

lib/pktcache: improved ranking of cached pkts

when no validation is attempted, trust level is 'bad'
when validation attempted but insecure, trust level is 'insecure'
otherwise 'secure'
parent 822d8fe2
Branches
Tags
No related merge requests found
......@@ -54,7 +54,7 @@ static int loot_cache_pkt(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_
}
/* Check that we have secure rank. */
if (want_secure && entry->rank == KR_RANK_INSECURE) {
if (want_secure && entry->rank == KR_RANK_BAD) {
return kr_error(ENOENT);
}
......@@ -195,10 +195,17 @@ static int stash(knot_layer_t *ctx, knot_pkt_t *pkt)
struct kr_cache_entry header = {
.timestamp = qry->timestamp.tv_sec,
.ttl = ttl,
.rank = (qry->flags & QUERY_DNSSEC_WANT) ? KR_RANK_SECURE : KR_RANK_INSECURE,
.rank = KR_RANK_BAD,
.count = data.len
};
/* Set cache rank */
if (qry->flags & QUERY_DNSSEC_WANT) {
header.rank = KR_RANK_SECURE;
} else if (qry->flags & QUERY_DNSSEC_INSECURE) {
header.rank = KR_RANK_INSECURE;
}
/* Stash answer in the cache */
int ret = kr_cache_insert(&txn, KR_CACHE_PKT, qname, qtype, &header, data);
if (ret != 0) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment