From adaed4ba4dcafb620bbce3075c0feaf6e3ea058d Mon Sep 17 00:00:00 2001 From: Marek Vavrusa Date: Thu, 21 Jan 2016 23:42:17 -0800 Subject: [PATCH] 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 --- daemon/lua/kres.lua | 1 + lib/resolve.c | 9 +++++++++ lib/rplan.h | 3 ++- lib/zonecut.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/daemon/lua/kres.lua b/daemon/lua/kres.lua index a041c3b70..58d49502c 100644 --- a/daemon/lua/kres.lua +++ b/daemon/lua/kres.lua @@ -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; }; /* diff --git a/lib/resolve.c b/lib/resolve.c index e104faf95..9d33847cc 100644 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -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); diff --git a/lib/rplan.h b/lib/rplan.h index f2e2cbaf3..836dcb76c 100644 --- a/lib/rplan.h +++ b/lib/rplan.h @@ -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; }; diff --git a/lib/zonecut.h b/lib/zonecut.h index b87f80cda..823a258ae 100644 --- a/lib/zonecut.h +++ b/lib/zonecut.h @@ -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. */ }; -- 2.47.2