Skip to content
Snippets Groups Projects
Verified Commit 77f5445f authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

modules: fix issues with dropped answers

parent 5830ecee
Branches
Tags
1 merge request!1083server-side XDP support
......@@ -264,7 +264,8 @@ int kr_resolve_begin(struct kr_request *request, struct kr_context *ctx);
*
* It may return NULL, in which case it marks ->state with _FAIL and no answer will be sent.
* Only use this when it's guaranteed that there will be no delay before sending it.
* You don't need to call this in places where "resolver knows" that there will be no delay.
* You don't need to call this in places where "resolver knows" that there will be no delay,
* but even there you need to check if the ->answer is NULL (unless you check for _FAIL anyway).
*/
KR_EXPORT
knot_pkt_t * kr_request_ensure_answer(struct kr_request *request);
......
......@@ -136,9 +136,11 @@ static int dnstap_log(kr_layer_t *ctx) {
if (dnstap_dt->log_resp_pkt) {
const knot_pkt_t *rpkt = req->answer;
m.response_message.len = rpkt->size;
m.response_message.data = (uint8_t *)rpkt->wire;
m.has_response_message = true;
m.has_response_message = rpkt != NULL;
if (rpkt != NULL) {
m.response_message.len = rpkt->size;
m.response_message.data = (uint8_t *)rpkt->wire;
}
}
/* set query time to the timestamp of the first kr_query
......
......@@ -654,9 +654,14 @@ local debug_logfinish_cb = ffi.cast('trace_callback_f', function (req)
ffi.C.kr_log_req(req, 0, 0, 'dbg',
'following rrsets were marked as interesting:\n' ..
req:selected_tostring())
ffi.C.kr_log_req(req, 0, 0, 'dbg',
'answer packet:\n' ..
tostring(req.answer))
if req.answer ~= nil then
ffi.C.kr_log_req(req, 0, 0, 'dbg',
'answer packet:\n' ..
tostring(req.answer))
else
ffi.C.kr_log_req(req, 0, 0, 'dbg',
'answer packet DROPPED\n')
end
end)
ffi.gc(debug_logfinish_cb, free_cb)
......
......@@ -118,7 +118,7 @@ static inline int collect_key(char *key, const knot_dname_t *name, uint16_t type
return key_len + sizeof(type);
}
static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_pkt_t *pkt)
static void collect_sample(struct stat_data *data, struct kr_rplan *rplan)
{
/* Sample key = {[2] type, [1-255] owner} */
char key[sizeof(uint16_t) + KNOT_DNAME_MAXLEN];
......@@ -208,9 +208,14 @@ static int collect(kr_layer_t *ctx)
struct kr_rplan *rplan = &param->rplan;
struct stat_data *data = module->data;
collect_sample(data, rplan);
if (!param->answer) {
/* The answer is being dropped. TODO: perhaps add some stat for this? */
return ctx->state;
}
/* Collect data on final answer */
collect_answer(data, param->answer);
collect_sample(data, rplan, param->answer);
/* Count cached and unresolved */
if (rplan->resolved.len > 0) {
/* Histogram of answer latency. */
......
......@@ -4,6 +4,7 @@ M.layer = {}
local ffi = require('ffi')
function M.layer.finish(state, req, pkt)
if pkt == nil then return end
-- fast filter by the length of the first QNAME label
if pkt.wire[5] == 0 then return state end -- QDCOUNT % 256 == 0, in case we produced that
local label_len = pkt.wire[12]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment