]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
make policy.PASS also affect the new-policy rules
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 11 Feb 2022 10:44:00 +0000 (11:44 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 12 Jun 2023 08:32:27 +0000 (10:32 +0200)
daemon/lua/kres-gen-30.lua
daemon/lua/kres-gen-31.lua
daemon/lua/kres-gen-32.lua
lib/cache/api.c
lib/rplan.h
modules/daf/daf.test.lua
modules/policy/policy.lua

index 9ad421a1f908738fcb6f35d12d557358807b584d..3cfcf4f3d58fcb3c5b74649dd28de6cb3b1e24b0 100644 (file)
@@ -134,6 +134,7 @@ struct kr_qflags {
        _Bool NO_NS_FOUND : 1;
        _Bool PKT_IS_SANE : 1;
        _Bool DNS64_DISABLE : 1;
+       _Bool PASSTHRU_LEGACY : 1;
 };
 typedef struct ranked_rr_array_entry {
        uint32_t qry_uid;
index 434adcfdf22503c42a91275fe7acd8625d24e0a2..55ef09627ad4c269e95d1661da5dfa90e3bee7a7 100644 (file)
@@ -134,6 +134,7 @@ struct kr_qflags {
        _Bool NO_NS_FOUND : 1;
        _Bool PKT_IS_SANE : 1;
        _Bool DNS64_DISABLE : 1;
+       _Bool PASSTHRU_LEGACY : 1;
 };
 typedef struct ranked_rr_array_entry {
        uint32_t qry_uid;
index 812397b2ff5a88e2174e22a5a36311db1e87cc46..c8b1d1a88dff736ae258371df3165ca4f1b02b62 100644 (file)
@@ -135,6 +135,7 @@ struct kr_qflags {
        _Bool NO_NS_FOUND : 1;
        _Bool PKT_IS_SANE : 1;
        _Bool DNS64_DISABLE : 1;
+       _Bool PASSTHRU_LEGACY : 1;
 };
 typedef struct ranked_rr_array_entry {
        uint32_t qry_uid;
index 501d68398fca85ae41b29d6c3de9bd5ec54d7620..804de6f80aa253b58a2f7b7b58243fb91b295ede 100644 (file)
@@ -340,12 +340,14 @@ int cache_peek(kr_layer_t *ctx, knot_pkt_t *pkt)
 
        /* TODO: we _might_ want to process rules here even when some of the cache
         * exit-conditions happen, though I don't expect these cases to be important. */
-       int ret = kr_rule_local_data_answer(qry, pkt);
-       if (ret != -ENOENT) {
-               return ret;
+       if (!req->options.PASSTHRU_LEGACY) {
+               int ret = kr_rule_local_data_answer(qry, pkt);
+               if (ret != -ENOENT) {
+                       return ret;
+               }
        }
 
-       ret = peek_nosync(ctx, pkt);
+       int ret = peek_nosync(ctx, pkt);
        kr_cache_commit(&req->ctx->cache);
        return ret;
 }
index 7ae33f2126cfea9c47135dbfcc315fb832950fdb..09dec987d8964a11b650b46b6953b019cd4cb1b9 100644 (file)
@@ -56,6 +56,7 @@ struct kr_qflags {
        bool PKT_IS_SANE : 1;    /**< Set by iterator in consume phase to indicate whether
                                  * some basic aspects of the packet are OK, e.g. QNAME. */
        bool DNS64_DISABLE : 1;  /**< Don't do any DNS64 stuff (meant for view:addr). */
+       bool PASSTHRU_LEGACY : 1;/**< Ignore local-data overrides/blocks for this kr_request. */
 };
 
 /** Combine flags together.  This means set union for simple flags. */
index 2a46393bc8a9e07900ac2d0b75ee9845542a7a62..557c1a997b348f5f22d0649ef6845ea5dce17e7f 100644 (file)
@@ -37,7 +37,9 @@ local function test_basic_actions()
        daf.add('qname = deny. deny')
        daf.add('qname = drop. drop')
 
-       check_answer('daf pass action', 'pass.', kres.type.A, kres.rcode.NOERROR)
+       -- This one won't work anymore, as PASS(THRU) now also skips hints.
+       --check_answer('daf pass action', 'pass.', kres.type.A, kres.rcode.NOERROR)
+
        check_answer('daf deny action', 'deny.', kres.type.A, kres.rcode.NXDOMAIN)
        check_answer('daf drop action', 'drop.', kres.type.A, kres.rcode.SERVFAIL)
 end
index 4715b007fca58416e6a3c152a8c92629b0775f87..5b2910e299763f6aab339b5aa370f50bb33eabf4 100644 (file)
@@ -71,7 +71,8 @@ end
 -- policy functions are defined below
 local policy = {}
 
-function policy.PASS(state, _)
+function policy.PASS(state, req)
+       policy.FLAGS('PASSTHRU_LEGACY')(state, req)
        return state
 end