]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
bump required Knot DNS version to 2.9
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 10 Feb 2021 15:01:17 +0000 (16:01 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 11 Feb 2021 16:18:40 +0000 (17:18 +0100)
15 files changed:
daemon/lua/kres-gen.lua
daemon/lua/kres-gen.sh
daemon/lua/kres.lua
distro/deb/control
distro/rpm/knot-resolver.spec
doc/build.rst
doc/upgrading.rst
lib/cache/entry_rr.c
lib/cache/impl.h
lib/utils.c
lib/zonecut.c
lib/zonecut.h
meson.build
modules/edns_keepalive/edns_keepalive.c
modules/nsid/nsid.c

index c4288530a1ebc614f54b4759aa985aae743cf048..6ae0557b311b4f03427614477fea2d04027fee73 100644 (file)
@@ -14,6 +14,15 @@ typedef struct {
        uint16_t compress_ptr[16];
 } knot_rrinfo_t;
 typedef unsigned char knot_dname_t;
+typedef struct {
+       uint16_t len;
+       uint8_t data[];
+} knot_rdata_t;
+typedef struct {
+       uint16_t count;
+       uint32_t size;
+       knot_rdata_t *rdata;
+} knot_rdataset_t;
 
 typedef struct knot_mm {
        void *ctx, *alloc, *free;
index 4b25f714d1d3604a78c90edb98efbe285e1f6961..e4745a8a5bf3df4d60bd9677401fca0a2a193b44 100755 (executable)
@@ -64,8 +64,8 @@ ${CDEFS} ${LIBKRES} types <<-EOF
        knot_section_t
        knot_rrinfo_t
        knot_dname_t
-       #knot_rdata_t
-       #knot_rdataset_t
+       knot_rdata_t
+       knot_rdataset_t
 EOF
 
 # The generator doesn't work well with typedefs of functions.
index 3bc2dbf7f16a41738c843ccf45ff556895c2e43b..640d8427d734966ef19595711993fc60a09d7e64 100644 (file)
@@ -46,6 +46,7 @@ struct sockaddr {
     uint16_t sa_family;
     uint8_t _stub[]; /* Do not touch */
 };
+
 struct knot_error {
        int code;
 };
@@ -59,40 +60,6 @@ int inet_pton(int af, const char *src, void *dst);
 int gettimeofday(struct timeval *tv, struct timezone *tz);
 ]]
 
-
--- TMP: compatibility with both libknot 2.8 and 2.9
-local knot_rdataset_t_cdef
-local sover_pos = string.find(libknot_SONAME, '%d')
-if not sover_pos then
-       error('unexpected libknot soname: ' .. libknot_SONAME)
-end
-local sover = string.sub(libknot_SONAME, sover_pos , sover_pos)
-if sover == '9' then
-       knot_rdataset_t_cdef = [[
-               typedef struct {
-                       uint16_t count;
-                       knot_rdata_t *rdata;
-               } knot_rdataset_t;
-       ]]
-elseif sover == '1' then -- it's 10 really, but this is simpler
-       knot_rdataset_t_cdef = [[
-               typedef struct {
-                       uint16_t count;
-                       uint32_t size;
-                       knot_rdata_t *rdata;
-               } knot_rdataset_t;
-       ]]
-else
-       error('unexpected libknot version: ' .. sover)
-end
-ffi.cdef([[
-               typedef struct {
-                       uint16_t len;
-                       uint8_t data[];
-               } knot_rdata_t;
-       ]] .. knot_rdataset_t_cdef)
-
-
 require('kres-gen')
 
 -- Error code representation
index ac9f5b9fad7a357e73de88ea01e8c9cd3da823d3..8c4432305c6c5bdc81b8bb3e43bafae478b1b8c6 100644 (file)
@@ -10,7 +10,7 @@ Build-Depends:
  libedit-dev,
  libfstrm-dev,
  libgnutls28-dev,
- libknot-dev (>= 2.8),
+ libknot-dev (>= 2.9),
  liblmdb-dev,
  libluajit-5.1-dev,
  libnghttp2-dev,
index 7d43bbc036990b5338eb061742081ce7da2d213b..ef4c8677c1f224dcabd227cb53ff4ba1822e8c5b 100644 (file)
@@ -42,9 +42,9 @@ BuildRequires:  meson
 BuildRequires:  pkgconfig(cmocka)
 BuildRequires:  pkgconfig(gnutls)
 BuildRequires:  pkgconfig(libedit)
-BuildRequires:  pkgconfig(libknot) >= 2.8
-BuildRequires:  pkgconfig(libzscanner) >= 2.8
-BuildRequires:  pkgconfig(libdnssec) >= 2.8
+BuildRequires:  pkgconfig(libknot) >= 2.9
+BuildRequires:  pkgconfig(libzscanner) >= 2.9
+BuildRequires:  pkgconfig(libdnssec) >= 2.9
 BuildRequires:  pkgconfig(libnghttp2)
 BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  pkgconfig(libcap-ng)
index 095568f73c90cb2b9f36713ce5ae091957ffed07..9e854505d5b1614423a5fefc2e342021c9774a56 100644 (file)
@@ -33,7 +33,7 @@ The following dependencies are needed to build and run Knot Resolver:
    "meson >= 0.46", "*build only* [#]_"
    "C and C++ compiler", "*build only* [#]_"
    "`pkg-config`_", "*build only* [#]_"
-   "libknot_ 2.8+", "Knot DNS libraries"
+   "libknot_ 2.9+", "Knot DNS libraries"
    "LuaJIT_ 2.0+", "Embedded scripting language"
    "libuv_ 1.7+", "Multiplatform I/O and services"
    "lmdb", "Memory-mapped database for cache"
index 054f2719633a97fa817da7b331a974baf75e9863..ff739f7a14c9252f21a747f42d5b462b91727ba3 100644 (file)
@@ -38,6 +38,10 @@ Configuration file
 
 * Module ``dnstap``: option ``log_responses`` has been moved inside a new ``client`` section. Refer to the configuration example in :ref:`mod-dnstap`.
 
+Packagers & Developers
+----------------------
+
+* Knot DNS >= 2.9 is required.
 
 5.1 to 5.2
 ==========
index 37359629f602bd47b2849ff9d064e9981e1b9b8d..5e7d26f2e9faffd068607fad612c6b45e820b020 100644 (file)
@@ -24,9 +24,8 @@ int rdataset_dematerialize(const knot_rdataset_t *rds, uint8_t * restrict data)
        memcpy(data, &rr_count, sizeof(rr_count));
        data += sizeof(rr_count);
        if (rr_count) {
-               size_t size = knot_rdataset_size(rds);
-               memcpy(data, rds->rdata, size);
-               data += size;
+               memcpy(data, rds->rdata, rds->size);
+               data += rds->size;
        }
        //VERBOSE_MSG(NULL, "dematerialized to %d B\n", (int)(data - data0));
        (void)data;
@@ -45,12 +44,9 @@ static int rdataset_materialize(knot_rdataset_t * restrict rds, const uint8_t *
        const uint8_t *d = data; /* iterates over the cache data */
        /* First sum up the sizes for wire format length. */
        /* TODO: we might overrun here already, but we need to trust cache anyway...*/
-       const uint32_t rds_size = rdataset_dematerialized_size(d, &rds->count);
+       rds->size = rdataset_dematerialized_size(d, &rds->count);
        d += KR_CACHE_RR_COUNT_SIZE;
-       #if KNOT_VERSION_HEX >= 0x020900
-               rds->size = rds_size;
-       #endif
-       if (d + rds_size > data_bound) {
+       if (d + rds->size > data_bound) {
                VERBOSE_MSG(NULL, "materialize: EILSEQ!\n");
                return kr_error(EILSEQ);
        }
@@ -58,12 +54,12 @@ static int rdataset_materialize(knot_rdataset_t * restrict rds, const uint8_t *
                rds->rdata = NULL;
                return d - data;
        }
-       rds->rdata = mm_alloc(pool, rds_size);
+       rds->rdata = mm_alloc(pool, rds->size);
        if (!rds->rdata) {
                return kr_error(ENOMEM);
        }
-       memcpy(rds->rdata, d, rds_size);
-       d += rds_size;
+       memcpy(rds->rdata, d, rds->size);
+       d += rds->size;
        //VERBOSE_MSG(NULL, "materialized from %d B\n", (int)(d - data));
        return d - data;
 }
index 6751cf1a183932af3bf98e09576a4ab7d6d3714d..b884c361a437810949c1d481cbbe11c0f7c3569e 100644 (file)
@@ -292,7 +292,7 @@ int32_t get_new_ttl(const struct entry_h *entry, const struct kr_query *qry,
 /** Compute size of serialized rdataset.  NULL is accepted as empty set. */
 static inline int rdataset_dematerialize_size(const knot_rdataset_t *rds)
 {
-       return KR_CACHE_RR_COUNT_SIZE + (rds == NULL ? 0 : knot_rdataset_size(rds));
+       return KR_CACHE_RR_COUNT_SIZE + (rds == NULL ? 0 : rds->size);
 }
 
 /** Analyze the length of a dematerialized rdataset.
index a13a615e2bf49e9ec5b4ad44aeb7a7d1517dce80..4aad3051465cf6c6cdabe244f77f91668a298535 100644 (file)
@@ -824,19 +824,16 @@ int kr_ranked_rrarray_finalize(ranked_rr_array_t *array, uint32_t qry_uid, knot_
                                }
                        }
                        /* Prepare rdataset, except rdata contents. */
-                       int size_sum = 0;
+                       knot_rdataset_t *rds = &stashed->rr->rrs;
+                       rds->size = 0;
                        for (int i = 0; i < ra->len; ++i) {
                                if (ra->at[i]) {
-                                       size_sum += knot_rdata_size(ra->at[i]->len);
+                                       rds->size += knot_rdata_size(ra->at[i]->len);
                                }
                        }
-                       knot_rdataset_t *rds = &stashed->rr->rrs;
                        rds->count = ra->len - dup_count;
-                       #if KNOT_VERSION_HEX >= 0x020900
-                               rds->size = size_sum;
-                       #endif
-                       if (size_sum) {
-                               rds->rdata = mm_alloc(pool, size_sum);
+                       if (rds->size) {
+                               rds->rdata = mm_alloc(pool, rds->size);
                                if (!rds->rdata) {
                                        return kr_error(ENOMEM);
                                }
@@ -846,13 +843,13 @@ int kr_ranked_rrarray_finalize(ranked_rr_array_t *array, uint32_t qry_uid, knot_
                        /* Everything is ready; now just copy all the rdata. */
                        uint8_t *raw_it = (uint8_t *)rds->rdata;
                        for (int i = 0; i < ra->len; ++i) {
-                               if (ra->at[i] && size_sum/*linters*/) {
+                               if (ra->at[i] && rds->size/*linters*/) {
                                        const int size = knot_rdata_size(ra->at[i]->len);
                                        memcpy(raw_it, ra->at[i], size);
                                        raw_it += size;
                                }
                        }
-                       assert(raw_it == (uint8_t *)rds->rdata + size_sum);
+                       assert(raw_it == (uint8_t *)rds->rdata + rds->size);
                }
                stashed->in_progress = false;
        }
index 7227bf9c0982f613e3e788e1a16a1bb4f9ef8ab0..cf7bfea4610e3a981cdb1999dd51fab4bd085440 100644 (file)
@@ -322,7 +322,7 @@ static addrset_info_t fetch_addr(pack_t *addrs, const knot_dname_t *ns, uint16_t
 
        /* Reserve memory in *addrs.  Implementation detail:
         * pack_t cares for lengths, so we don't store those in the data. */
-       const size_t pack_extra_size = knot_rdataset_size(&cached_rr.rrs)
+       const size_t pack_extra_size = cached_rr.rrs.size
                - cached_rr.rrs.count * offsetof(knot_rdata_t, len);
        int ret = pack_reserve_mm(*addrs, cached_rr.rrs.count, pack_extra_size,
                                  kr_memreserve, mm_pool);
index 8800e6703ec5125e8eccda99aa3110fe4e7fe263..56ca834d41fcfd8d8eb56578cdd3ed6c18f59b55 100644 (file)
 #include "lib/generic/trie.h"
 
 
-/* TMP: compatibility for using libknot 2.8 API with 2.9. */
-#if KNOT_VERSION_HEX >= 0x020900
-static inline size_t knot_rdataset_size(const knot_rdataset_t *rrs)
-{
-       return rrs->size;
-}
-#endif
-
 struct kr_rplan;
 struct kr_context;
 
@@ -127,7 +119,7 @@ int kr_zonecut_del_all(struct kr_zonecut *cut, const knot_dname_t *ns);
  *
  * @note This can be used for membership test, a non-null pack is returned
  *       if the nameserver name exists.
- * 
+ *
  * @param  cut
  * @param  ns    name server name
  * @return       pack of addresses or NULL
index 9c026302cb543506f160c25a01eb4726b291c93d..2f6509a2e7db14e3408090ad13b9232be226f495 100644 (file)
@@ -18,7 +18,7 @@ endif
 
 
 message('--- required dependencies ---')
-knot_version = '>=2.8'
+knot_version = '>=2.9'
 libknot = dependency('libknot', version: knot_version)
 libdnssec = dependency('libdnssec', version: knot_version)
 libzscanner = dependency('libzscanner', version: knot_version)
index ebf26aab7ee90b9da4357645625edffb1dde85dd..3d379f51011dbdb8a52bce211f63ce2d49e09e09 100644 (file)
@@ -24,11 +24,7 @@ static int edns_keepalive_finalize(kr_layer_t *ctx)
        const bool ka_want =
                req->qsource.flags.tcp &&
                src_opt != NULL &&
-               knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_TCP_KEEPALIVE
-                                       #if KNOT_VERSION_HEX >= 0x020900
-                                               , NULL
-                                       #endif
-                               ) &&
+               knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_TCP_KEEPALIVE, NULL) &&
                answ_opt != NULL;
        if (!ka_want) {
                return ctx->state;
index fa7a4947a6ce37750cdbf011248a9f0d9b21bbbb..c0eabfdc487f4c9f2bba89915784423c9a55674f 100644 (file)
@@ -30,11 +30,7 @@ static int nsid_finalize(kr_layer_t *ctx) {
        if (src_opt == NULL)
                return ctx->state;
 
-       const uint8_t *req_nsid = knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_NSID
-                                                       #if KNOT_VERSION_HEX >= 0x020900
-                                                               , NULL
-                                                       #endif
-                                                       );
+       const uint8_t *req_nsid = knot_edns_get_option(src_opt, KNOT_EDNS_OPTION_NSID, NULL);
        /* NSID option must be explicitly requested */
        if (req_nsid == NULL)
                return ctx->state;