Since today, kresd started crashing on startup for no reason:
2021-01-26 20:39:08 info kresd[8645]: [ta_update] refreshing TA for .
2021-01-26 20:39:08 info kresd[8645]: [ta_update] next refresh for . in 24 hours
2021-01-26 20:39:16 err kresd[8645]: Assertion failed: pkt && pkt->wire (../lib/utils.c: kr_pkt_make_auth_header: 320)
It looks like something in my custom configuration that was previously working is now failing. Checking.
EDIT:
This breaks:
local ffi = require('ffi')
local function genRR (state, req)
local answer = req.answer
local qry = req:current()
if qry.stype ~= kres.type.A then
return state
end
ffi.C.kr_pkt_make_auth_header(answer)
answer:rcode(kres.rcode.NOERROR)
answer:begin(kres.section.ANSWER)
answer:put(qry.sname, 900, answer:qclass(), kres.type.A, '\192\168\10\67')
return kres.DONE
end
policy.add(policy.suffix(genRR, { todname('internal.xxx.net.') }))
@vcunat Does the domain being checked by the above require a valid DNSSEC entry? Because the domain registrar does not offer DNSSEC.
And if I add
if answer == nil then return nil end
before the first if, it does not crash, but the function does not work anymore.
EDIT: It looks that the policy is only applied if the record hits a NXDOMAIN. I assume this is the case because of the FQDN on the router.
- local answer = req.answer
+ local answer = req:ensure_answer()
+ if answer == nil then return nil end
(well, the second line most likely won’t ever be needed in your case, but it’s just cleaner)
EDIT: it’s perhaps unpleasant that ensure_answer didn’t exist until 5.2.0, so you need to apply the change at the right time (or make it all more complicated).
Thanks, your answer came right as I dug through the API docs.
Here’s the fixed version for posterity:
local function genRR (state, req)
local answer = req:ensure_answer()
local qry = req:current()
if answer == nil then return nil end
if qry.stype ~= kres.type.A then
return state
end
ffi.C.kr_pkt_make_auth_header(answer)
answer:rcode(kres.rcode.NOERROR)
answer:begin(kres.section.ANSWER)
answer:put(qry.sname, 900, answer:qclass(), kres.type.A, '\192\168\10\67')
return kres.DONE
end
No, it wasn’t, I’m afraid. 5.2.0 removed the guarantee that answer packet always exists and at the same time added the ensure_answer helper for this. I didn’t realize we’ve suggested to put this into configuration on a couple places in this forum. It’s marked as incompatible change in 5.2.0 and its upgrade guide, but typically Turris users don’t need to care about that, so it wasn’t even linked from Turris NEWS.
Nice! It’s much simpler and concise. I’ll adjust my configuration after reading the documentation. Does that work with single entries, or multiples, e.g. todnames({"foo.bar.baz", "baz.bar.baz"})?