eh_orig = entry_h_consistent(val, type);
}
} else {
+ /* We want to fully overwrite the entry, so don't even read it. */
memset(el, 0, sizeof(el));
}
{
/* We assume it's zeroed. Do basic sanity check. */
if (ans->rrsets[id].set.rr || ans->rrsets[id].sig_rds.data
- /* || (type == KNOT_RRTYPE_NSEC && ans->nsec_v != 1)
- || (type == KNOT_RRTYPE_NSEC3 && ans->nsec_v != 3)
- */ )
+ || (type == KNOT_RRTYPE_NSEC && ans->nsec_p.raw)
+ || (type == KNOT_RRTYPE_NSEC3 && !ans->nsec_p.raw)
+ )
{
assert(false);
return kr_error(EINVAL);
ans->rrsets[id].set.rank = eh->rank;
ans->rrsets[id].set.expiring = is_expiring(eh->ttl, new_ttl);
/* Materialize the RRSIG RRset for the answer in (pseudo-)packet. */
- bool want_rrsigs = true; // TODO
+ bool want_rrsigs = true; /* LATER(optim.): might be omitted in some cases. */
if (want_rrsigs) {
ret = rdataset_materialize(&ans->rrsets[id].sig_rds, eh->data + data_off,
eh_bound, new_ttl, ans->mm);
if (ret < 0) goto fail;
-
- // TODO
- #if 0
- /* sanity check: we consumed exactly all data */
- int unused_bytes = eh_bound - (void *)eh->data - data_off - ret;
- if (ktype != KNOT_RRTYPE_NS && unused_bytes) {
- /* ^^ it doesn't have to hold in multi-RRset entries; LATER: more checks? */
- VERBOSE_MSG(qry, "BAD? Unused bytes: %d\n", unused_bytes);
+ /* Sanity check: we consumed exactly all data. */
+ int unused_bytes = eh_bound - (uint8_t *)eh->data - data_off - ret;
+ if (unused_bytes) {
+ kr_log_error("[cach] entry2answer ERROR: unused bytes: %d\n",
+ unused_bytes);
+ assert(!EILSEQ);
+ ret = kr_error(EILSEQ);
+ goto fail; /* to be on the safe side */
}
- #endif
}
return kr_ok();
fail:
enum { ENTRY_APEX_NSECS_CNT = 2 };
-/** Header of 'E' entry with ktype == NS. Inside is private to ./entry_list.c */
+/** Header of 'E' entry with ktype == NS. Inside is private to ./entry_list.c
+ *
+ * We store xNAME at NS type to lower the number of searches in closest_NS().
+ * CNAME is only considered for equal name, of course.
+ * We also store NSEC* parameters at NS type.
+ */
struct entry_apex {
/* ENTRY_H_FLAGS */
bool has_ns : 1;
int nsec3_encloser(struct key *k, struct answer *ans,
const int sname_labels, int *clencl_labels,
const struct kr_query *qry, struct kr_cache *cache)
- /* TODO: cleanup params */
{
static const int ESKIP = ABS(ENOENT);
/* Basic sanity check. */
int nsec3_src_synth(struct key *k, struct answer *ans, const knot_dname_t *clencl_name,
const struct kr_query *qry, struct kr_cache *cache)
- /* TODO: cleanup params */
{
/* Find a previous-or-equal NSEC3 in cache covering or matching
* the source of synthesis, checking TTL etc. */
}
/** Find the longest prefix zone/xNAME (with OK time+rank), starting at k->*.
- * We store xNAME at NS type to lower the number of searches.
- * CNAME is only considered for equal name, of course.
- * We also store NSEC* parameters at NS type; probably the latest two will be kept.
- * Found type is returned via k->type.
*
- * \return raw entry from cache (for NS) or rewound entry (xNAME) FIXME
+ * Found type is returned via k->type; the values are returned in el.
+ * \return error code
*/
static int closest_NS(kr_layer_t *ctx, struct key *k, entry_list_t el)
{