]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/resolve: new flag ALWAYS_CUT
authorMarek Vavrusa <marek@vavrusa.com>
Fri, 22 Jan 2016 07:42:17 +0000 (23:42 -0800)
committerMarek Vavrusa <marek@vavrusa.com>
Fri, 22 Jan 2016 07:42:30 +0000 (23:42 -0800)
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
lib/resolve.c
lib/rplan.h
lib/zonecut.h

index a041c3b7008d6aa11be3743aea1193db7297b2be..58d49502ca207fa3e6a1725e4032788fb96f1285 100644 (file)
@@ -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;
 };
 
 /*
index e104faf957cb1dbc15ef5823b569284de6493b00..9d33847ccd5bcdfca83eba27b0ecd57d1b9b9584 100644 (file)
@@ -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);
index f2e2cbaf33b0e3d5e942fb9424e826d0a2c6470b..836dcb76cc44d51eae5e1242a5f4e5b6b6614ea2 100644 (file)
@@ -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;
 };
 
index b87f80cda691012375bb3d8f0415ff6d429c1cce..823a258aedd40454b2e8ac31f454b66b408ebb69 100644 (file)
@@ -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. */
 };