]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/dnstap: nitpicks
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 22 Feb 2017 12:50:10 +0000 (13:50 +0100)
committerOndřej Surý <ondrej@sury.org>
Mon, 6 Mar 2017 11:48:45 +0000 (12:48 +0100)
Makefile
daemon/lua/kres-gen.lua
doc/build.rst
lib/resolve.h
modules/dnstap/dnstap.c
tests/dnstap/src/dnstap-test/dnstap.mk
tests/tests.mk

index fb91140324bb181aad09cf13a9cb6ccb0dd36272..e4f5dbe61513ed5c21db2783441e830793fa882c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -75,7 +75,6 @@ endif
 
 # check for fstrm and protobuf for dnstap
 ifeq ($(HAS_libfstrm)|$(HAS_libprotobuf-c),yes|yes)
-BUILD_CFLAGS += -DENABLE_DNSTAP
 ENABLE_DNSTAP := yes
 endif
 
index eca33cf76bdd0c51b2511f0cad1a089d4ac41170..309db5c9c23b5e6a21b132a8895bee78ec30f4fc 100644 (file)
@@ -107,6 +107,7 @@ struct kr_request {
                const struct sockaddr *dst_addr;
                const knot_pkt_t *packet;
                const knot_rrset_t *opt;
+               _Bool tcp;
        } qsource;
        struct {
                unsigned int rtt;
index d0b53a5bc7b816aa35a0c1996cc3df7c97c2e7f4..2b054b5dd012b30d788e81075c0f6dbb8f13718f 100644 (file)
@@ -234,7 +234,8 @@ The project can be built with code coverage tracking using the ``COVERAGE=1`` va
 Running unit and integration tests
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The unit tests require cmocka_ and are executed with ``make check``.
+The unit tests require cmocka_ and are executed by ``make check``.
+Tests for the dnstap module need go and are executed by ``make ckeck-dnstap``.
 
 The integration tests use Deckard, the `DNS test harness <deckard>`_.
 
index c5c31cad224b77c374146c6a3ea0f29c6834b4de..b0dd2d01d3bab451e3097faff496ee565de67a55 100644 (file)
@@ -133,7 +133,7 @@ struct kr_request {
                const struct sockaddr *dst_addr;
                const knot_pkt_t *packet;
                const knot_rrset_t *opt;
-               bool tcp; /* true if the query is on tcp */
+               bool tcp; /**< true if the request is on tcp; only meaningful if (dst_addr) */
        } qsource;
        struct {
                unsigned rtt;                  /**< Current upstream RTT */
index 54914b09a6da0e16ad9a0ee85d5d9885984049b4..872105ccf938336e4c7453974c30401a8328e4c0 100644 (file)
@@ -102,10 +102,10 @@ static void set_address(const struct sockaddr *sockaddr,
 
 /* dnstap_log prepares dnstap message and sent it to fstrm */
 static int dnstap_log(kr_layer_t *ctx) {
-       struct kr_request *req = ctx->req;
-       struct kr_module *module = ctx->api->data;
-       struct kr_rplan *rplan = &req->rplan;
-       struct dnstap_data *dnstap_dt = module->data;
+       const struct kr_request *req = ctx->req;
+       const struct kr_module *module = ctx->api->data;
+       const struct kr_rplan *rplan = &req->rplan;
+       const struct dnstap_data *dnstap_dt = module->data;
 
        /* check if we have a valid iothread */
        if (!dnstap_dt->iothread || !dnstap_dt->ioq) {
@@ -126,13 +126,6 @@ static int dnstap_log(kr_layer_t *ctx) {
        /* Only handling response */
        m.type = DNSTAP__MESSAGE__TYPE__RESOLVER_RESPONSE;
 
-       if (req->qsource.tcp) {
-               m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__TCP;
-       } else {
-               m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__UDP;
-       }
-       m.has_socket_protocol = true;
-
        if (req->qsource.addr) {
                set_address(req->qsource.addr,
                                &m.query_address,
@@ -142,6 +135,13 @@ static int dnstap_log(kr_layer_t *ctx) {
        }
 
        if (req->qsource.dst_addr) {
+               if (req->qsource.tcp) {
+                       m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__TCP;
+               } else {
+                       m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__UDP;
+               }
+               m.has_socket_protocol = true;
+
                set_address(req->qsource.dst_addr,
                                &m.response_address,
                                &m.has_response_address,
@@ -303,17 +303,6 @@ static int find_string(const JsonNode *node, char **val, size_t len) {
        return kr_ok();
 }
 
-/* find_int copies json int into val
- * node must be of type JSON_NUMBER */
-static int find_int(const JsonNode *node, int *val) {
-       if (!node || !node->key || !val) {
-               return kr_error(EINVAL);
-       }
-       assert(node->tag == JSON_NUMBER);
-       *val = node->number_;
-       return kr_ok();
-}
-
 /* find_bool returns bool from json */
 static bool find_bool(const JsonNode *node) {
        if (!node || !node->key) {
index f6dce7184527a96f696dd81ee1239d43750395ee..0711707e1107582047bd6491bc82d2d8e7ac85d2 100644 (file)
@@ -6,12 +6,12 @@ CONFIG := $(DNSTAP_PATH)/config
 CMD := daemon/kresd
 ZONES := "fake1.localdomain,fake2.localdomain,fake3.localdomain"
 TIMEOUT := 60s
-check-dnstap:
+check-dnstap: daemon
        @echo "Checking dnstap functionality"
        GOPATH=$(GOPATH) go get -u github.com/FiloSottile/gvt
        cd $(DNSTAP_PATH) && $(GOPATH)/bin/gvt restore
        GOPATH=$(GOPATH) go install $(DNSTAP_TEST)
-       $(GOPATH)/bin/$(DNSTAP_TEST) -c $(CONFIG) -cmd $(CMD) -q $(ZONES) -t $(TIMEOUT) 
+       $(GOPATH)/bin/$(DNSTAP_TEST) -c $(CONFIG) -cmd $(CMD) -q $(ZONES) -t $(TIMEOUT)
 
 clean-dnstap:
        rm -rf $(GOPATH)/bin $(GOPATH)/pkg
index e85d92a084fd97bfc3e28f2d2bf672c71d431ccf..12c6331b7249b81d3ba102b7752113bff55de356 100644 (file)
@@ -29,6 +29,6 @@ deckard: check-integration
 
 # Targets
 tests: check-unit
-tests-clean: $(foreach test,$(tests_BIN),$(test)-clean) mock_cmodule-clean
+tests-clean: $(foreach test,$(tests_BIN),$(test)-clean) mock_cmodule-clean clean-dnstap
 
 .PHONY: tests tests-clean check-integration deckard