From 060349c9d643c1e38940fbd874cf7415dee043ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 11 Mar 2021 15:23:28 +0100 Subject: [PATCH] dnstap: don't break request resolution on dnstap errors This isn't a regression of 5.3.0 changes. Layer functions are supposed to return new values for ctx->state, but here we were sometimes returning kr_error(EFOO) which altered processing of the request. Our case: answers directly from policy module would not end up finishing the request and we'd hit an assert at the end of processing. --- NEWS | 6 +++++- modules/dnstap/dnstap.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 0498a5aeb..5fba50776 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,14 @@ -Knot Resolver 5.y.z (2021-0m-dd) +Knot Resolver 5.3.1 (2021-03-dd) ================================ Improvements ------------ - doh2: send HTTP error status codes (#618, !1102) +Bugfixes +-------- +- dnstap module: don't break request resolution on dnstap errors (!1147) + Knot Resolver 5.3.0 (2021-02-25) ================================ diff --git a/modules/dnstap/dnstap.c b/modules/dnstap/dnstap.c index 9dcb7bba1..6dd6f9512 100644 --- a/modules/dnstap/dnstap.c +++ b/modules/dnstap/dnstap.c @@ -93,7 +93,10 @@ static void set_address(const struct sockaddr *sockaddr, *has_port = true; } -/* dnstap_log prepares dnstap message and sends it to fstrm */ +/* dnstap_log prepares dnstap message and sends it to fstrm + * + * Return codes are kr_error(E*) and unused for now. + */ static int dnstap_log(kr_layer_t *ctx, enum dnstap_log_phase phase) { const struct kr_request *req = ctx->req; const struct kr_module *module = ctx->api->data; @@ -101,7 +104,7 @@ static int dnstap_log(kr_layer_t *ctx, enum dnstap_log_phase phase) { const struct dnstap_data *dnstap_dt = module->data; if (!req->qsource.addr) { - return ctx->state; + return kr_ok(); } /* check if we have a valid iothread */ @@ -232,17 +235,19 @@ static int dnstap_log(kr_layer_t *ctx, enum dnstap_log_phase phase) { return kr_error(EBUSY); } - return ctx->state; + return kr_ok(); } /* dnstap_log_query prepares dnstap CLIENT_QUERY message and sends it to fstrm */ static int dnstap_log_query(kr_layer_t *ctx) { - return dnstap_log(ctx, CLIENT_QUERY_PHASE); + dnstap_log(ctx, CLIENT_QUERY_PHASE); + return ctx->state; } /* dnstap_log_response prepares dnstap CLIENT_RESPONSE message and sends it to fstrm */ static int dnstap_log_response(kr_layer_t *ctx) { - return dnstap_log(ctx, CLIENT_RESPONSE_PHASE); + dnstap_log(ctx, CLIENT_RESPONSE_PHASE); + return ctx->state; } KR_EXPORT -- 2.47.2