From 2e2e0f8848b59951e81c79824e44b40beb349aa6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 15 Feb 2017 18:15:11 +0100 Subject: [PATCH] workarounds: add code to deal with #139 --- daemon/lua/kres-gen.lua | 9 +++++++++ daemon/lua/kres-gen.sh | 7 +++++-- modules/workarounds/workarounds.lua | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/daemon/lua/kres-gen.lua b/daemon/lua/kres-gen.lua index f69a33760..6ccab78b4 100644 --- a/daemon/lua/kres-gen.lua +++ b/daemon/lua/kres-gen.lua @@ -130,6 +130,13 @@ struct knot_rrset { knot_rdataset_t rrs; void *additional; }; +struct kr_nsrep { + unsigned int score; + unsigned int reputation; + const knot_dname_t *name; + struct kr_context *ctx; + /* beware: hidden stub */ +}; struct kr_query { struct kr_query *parent; knot_dname_t *sname; @@ -142,6 +149,8 @@ struct kr_query { uint16_t reorder; struct timeval timestamp; struct kr_zonecut zone_cut; + struct kr_nsrep ns; + /* ^hidden stub^ */ char _stub[]; }; struct kr_context { diff --git a/daemon/lua/kres-gen.sh b/daemon/lua/kres-gen.sh index dd803c06f..124853543 100755 --- a/daemon/lua/kres-gen.sh +++ b/daemon/lua/kres-gen.sh @@ -52,8 +52,11 @@ genResType "struct knot_rrset" | sed 's/\/_owner/' ## Some definitions would need too many deps, so shorten them. -genResType "struct kr_query" | sed '/struct kr_nsrep/,$ d' -printf "\tchar _stub[];\n};\n" +genResType "struct kr_nsrep" | sed '/union/,$ d' +printf "\t/* beware: hidden stub */\n};\n" + +genResType "struct kr_query" | sed '/struct kr_layer_pickle/,$ d' +printf "\t/* ^hidden stub^ */\n\tchar _stub[];\n};\n" genResType "struct kr_context" | sed '/struct kr_cache/,$ d' printf "\tchar _stub[];\n};\n" diff --git a/modules/workarounds/workarounds.lua b/modules/workarounds/workarounds.lua index 255fe7848..51cf3c087 100644 --- a/modules/workarounds/workarounds.lua +++ b/modules/workarounds/workarounds.lua @@ -16,5 +16,29 @@ function M.config() })) end +-- Issue #139: When asking NSs of certain turktelekom names for PTR, disable 0x20. +-- Just listing the *.in-addr.arpa suffixes would be tedious, as there are many. +M.layer = { + produce = function (state, req) + local req = kres.request_t(req) + local qry = req:current() + if qry.stype ~= kres.type.PTR + or bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 + then return state -- quick exit in most cases + end + if qry:hasflag(kres.query.AWAIT_CUT) or qry.ns.name == nil + then return state end + local name = kres.dname2str(qry.ns.name) + -- The problematic nameservers: rdnsN.turktelekom.com.tr. + if name and string.sub(name, 6) == '.turktelekom.com.tr.' then + qry.flags = bit.bor(qry.flags, + bit.bor(kres.query.NO_0X20, kres.query.NO_MINIMIZE)) + -- ^ NO_MINIMIZE isn't required for success, as kresd will retry + -- after getting refused, but it will speed things up. + end + return state + end, +} + return M -- 2.47.3