]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
policy.FLAGS: fix not applying properly in edge cases
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 17 May 2021 14:48:30 +0000 (16:48 +0200)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Wed, 23 Jun 2021 10:36:17 +0000 (12:36 +0200)
Perhaps this bug was now more pronounced since 5.3.0 changes.
Example problem was disabling minimization or 0x20 (globally or
for some problematic requests); without this change they would get
re-enabled during some fallback actions... which might be exactly
the wrong moment wrt. the motivation to setting these.
https://gitter.im/CZ-NIC/knot-resolver?at=60a221e86a950f3d46ed1cd9

NEWS
modules/policy/policy.lua

diff --git a/NEWS b/NEWS
index ec47b974ca1dac305cba8d4a1b647b2e02c1ed74..0c27d6c5acdadbeb3e747cd1c46bce97984f4333 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Bugfixes
 --------
 - trust_anchors.set_insecure: improve precision (#673, !1177)
 - plug memory leaks related to TCP (!1182)
+- policy.FLAGS: fix not applying properly in edge cases (!1179)
 
 Incompatible changes
 --------------------
index e7c0cdbfdea885c0a3af9d8597a57890c90e9952..1b450d84f269d7bff32ea86594e57eade86c227a 100644 (file)
@@ -193,9 +193,13 @@ end
 -- Set and clear some query flags
 function policy.FLAGS(opts_set, opts_clear)
        return function(_, req)
+               -- We assume to be running in the begin phase, so to truly apply
+               -- to the whole request we need to change both kr_request and kr_query.
                local qry = req:current()
-               ffi.C.kr_qflags_set  (qry.flags, kres.mk_qflags(opts_set   or {}))
-               ffi.C.kr_qflags_clear(qry.flags, kres.mk_qflags(opts_clear or {}))
+               for _, flags in pairs({qry.flags, req.options}) do
+                       ffi.C.kr_qflags_set  (flags, kres.mk_qflags(opts_set   or {}))
+                       ffi.C.kr_qflags_clear(flags, kres.mk_qflags(opts_clear or {}))
+               end
                return nil -- chain rule
        end
 end