From: Vladimír Čunát Date: Mon, 17 May 2021 14:48:30 +0000 (+0200) Subject: policy.FLAGS: fix not applying properly in edge cases X-Git-Tag: v5.4.0~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b298015670e4d9d6b21836f864cd78df47a2f83f;p=thirdparty%2Fknot-resolver.git policy.FLAGS: fix not applying properly in edge cases 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 --- diff --git a/NEWS b/NEWS index ec47b974c..0c27d6c5a 100644 --- 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 -------------------- diff --git a/modules/policy/policy.lua b/modules/policy/policy.lua index e7c0cdbfd..1b450d84f 100644 --- a/modules/policy/policy.lua +++ b/modules/policy/policy.lua @@ -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