Commit adaed4ba authored by Marek Vavrusa's avatar Marek Vavrusa

lib/resolve: new flag ALWAYS_CUT

when raised, a response zone cut will be recovered
even if the response came from cache. this is
normally not needed (and incurs additional cache
lookups), but it may be useful for
inspection
parent 05331a56
......@@ -103,6 +103,7 @@ struct query_flag {
static const int EXPIRING = 1 << 12;
static const int DNSSEC_WANT = 1 << 14;
static const int STUB = 1 << 17;
static const int ALWAYS_CUT = 1 << 18;
};
/*
......
......@@ -645,6 +645,15 @@ int kr_resolve_produce(struct kr_request *request, struct sockaddr **dst, int *t
RESUME_LAYERS(layer_id(request, pickle->api), request, qry, consume, pickle->pkt);
qry->deferred = pickle->next;
} else {
/* Caller is interested in always tracking a zone cut, even if the answer is cached
* this is normally not required, and incurrs another cache lookups for cached answer. */
if (qry->flags & QUERY_ALWAYS_CUT) {
switch(zone_cut_check(request, qry, packet)) {
case KNOT_STATE_FAIL: return KNOT_STATE_FAIL;
case KNOT_STATE_DONE: return KNOT_STATE_PRODUCE;
default: break;
}
}
/* Resolve current query and produce dependent or finish */
request->state = KNOT_STATE_PRODUCE;
ITERATE_LAYERS(request, qry, produce, packet);
......
......@@ -43,6 +43,7 @@
X(DNSSEC_BOGUS, 1 << 15) /**< Query response is DNSSEC bogus. */ \
X(DNSSEC_INSECURE, 1 << 16) /**< Query response is DNSSEC insecure. */ \
X(STUB, 1 << 17) /**< Stub resolution, accept received answer as solved. */ \
X(ALWAYS_CUT, 1 << 18) /**< Always recover zone cut (even if cached). */
/** Query flags */
enum kr_query_flag {
......@@ -67,8 +68,8 @@ struct kr_query {
uint32_t flags;
uint32_t secret;
struct timeval timestamp;
struct kr_nsrep ns;
struct kr_zonecut zone_cut;
struct kr_nsrep ns;
struct kr_layer_pickle *deferred;
};
......
......@@ -29,10 +29,10 @@ struct kr_context;
*/
struct kr_zonecut {
knot_dname_t *name; /**< Zone cut name. */
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. */
map_t nsset; /**< Map of nameserver => address_set. */
knot_mm_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