]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/policy: make postrules useful
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 23 Jan 2020 14:25:16 +0000 (15:25 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 23 Jan 2020 17:35:11 +0000 (18:35 +0100)
In finish() phase DONE is (almost?) always set, so it didn't make sense.
The mistake came from c16728f5 !678.

NEWS
modules/policy/policy.lua
modules/view/view.lua

diff --git a/NEWS b/NEWS
index 7e5cc940651a21189effbf85302287f404e45646..8845942a6a6f606f6d5a83a473ceba31dde3ecb0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,7 +20,7 @@ Improvements
 Bugfixes
 --------
 - correctly use EDNS(0) padding in failed answers (!921)
-- policy and daf modules: fix reroute rules (!901)
+- policy and daf modules: fix postrules and reroute rules (!901)
 - renumber module: don't accidentally zero-out request's .state (!901)
 
 
index d9da4d80031d8c7e4ca01003e7cb0ae442ac66d2..2c1886810eb55934d17d69bc6245af4377e679bb 100644 (file)
@@ -789,7 +789,7 @@ end
 -- as a dependency chain, e.g. r1,r2,r3 -> r3(r2(r1(state)))
 policy.layer = {
        begin = function(state, req)
-               -- Don't act on "resolved" cases.
+               -- Don't act on "finished" cases.
                if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
                local qry = req:current()
                return policy.evaluate(policy.rules, req, qry, state)
@@ -800,8 +800,8 @@ policy.layer = {
        finish = function(state, req)
                -- Optimization for the typical case
                if #policy.postrules == 0 then return state end
-               -- Don't act on "resolved" cases.
-               if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
+               -- Don't act on failed cases.
+               if bit.band(state, kres.FAIL) ~= 0 then return state end
                return policy.evaluate(policy.postrules, req, req:current(), state) or state
        end
 }
index 28b7d26b228f576fc268d1e48bbfdd04256655ff..dcc7117ffe38966f02c7935ca6d2dd59669b8fc2 100644 (file)
@@ -106,7 +106,7 @@ end
 -- @function Module layers
 view.layer = {
        begin = function(state, req)
-               -- Don't act on "resolved" cases.
+               -- Don't act on "finished" cases.
                if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
 
                evaluate(state, req)