]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
dnstap: don't break request resolution on dnstap errors
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 11 Mar 2021 14:23:28 +0000 (15:23 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 11 Mar 2021 14:30:55 +0000 (15:30 +0100)
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
modules/dnstap/dnstap.c

diff --git a/NEWS b/NEWS
index 0498a5aeb8de4ffaf249533bcd4147587f90c8e4..5fba50776895f6a332b469bf675f31a75f884afa 100644 (file)
--- 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)
 ================================
index 9dcb7bba1d757aa0cdfa1995aef6262467e42fd7..6dd6f951275329d48be776edf33c8da7cd12ef65 100644 (file)
@@ -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