Commit e71e9a5f authored by Marek Vavruša's avatar Marek Vavruša

lib/zonecut: remember parent zone cut when descending

parent bc3e363d
......@@ -225,7 +225,17 @@ static int update_cut(knot_pkt_t *pkt, const knot_rrset_t *rr, struct kr_request
/* Update zone cut name */
if (!knot_dname_is_equal(rr->owner, cut->name)) {
kr_zonecut_set(cut, rr->owner);
/* Remember parent cut and descend to new (keep keys and TA). */
struct kr_zonecut *parent = mm_alloc(&req->pool, sizeof(*parent));
if (parent) {
memcpy(parent, cut, sizeof(*parent));
kr_zonecut_init(cut, rr->owner, &req->pool);
cut->key = parent->key;
cut->trust_anchor = parent->trust_anchor;
cut->parent = parent;
} else {
kr_zonecut_set(cut, rr->owner);
}
state = KNOT_STATE_DONE;
}
......
......@@ -72,6 +72,7 @@ int kr_zonecut_init(struct kr_zonecut *cut, const knot_dname_t *name, mm_ctx_t *
cut->pool = pool;
cut->key = NULL;
cut->trust_anchor = NULL;
cut->parent = NULL;
cut->nsset = map_make();
cut->nsset.malloc = (map_alloc_f) mm_alloc;
cut->nsset.free = (map_free_f) mm_free;
......
......@@ -31,6 +31,7 @@ struct kr_zonecut {
map_t nsset; /**< Map of nameserver => address_set. */
knot_rrset_t* key; /**< Zone cut DNSKEY. */
knot_rrset_t* trust_anchor; /**< Current trust anchor. */
struct kr_zonecut *parent; /**< Parent zone cut. */
mm_ctx_t *pool; /**< Memory pool. */
};
......
Markdown is supported
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