]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
util: add kr_rrset_type_maysig(knot_rrset_t *)
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 31 Mar 2017 15:46:56 +0000 (17:46 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 31 Mar 2017 15:46:56 +0000 (17:46 +0200)
Also correct a tiny bug where iterator didn't skip RRSIGs that covered
non-interesting types of the name we desired.

lib/layer/iterate.c
lib/layer/rrcache.c
lib/utils.c
lib/utils.h

index 539d6c3c45c0fb68b5a2fb1eab8e022573a4c09b..4956e6c80e74a8d3f0cff7a7fb1d94a69ca838ee 100644 (file)
@@ -398,12 +398,10 @@ static int unroll_cname(knot_pkt_t *pkt, struct kr_request *req, bool referral,
                        const knot_rrset_t *rr = knot_pkt_rr(an, i);
 
                        /* Skip the RR if its owner+type doesn't interest us. */
-                       const bool type_OK = rr->type == query->stype
-                               || rr->type == KNOT_RRTYPE_CNAME
-                               || rr->type == KNOT_RRTYPE_DNAME /* TODO: actually handle it */
-                               || (rr->type == KNOT_RRTYPE_RRSIG
-                                   && knot_rrsig_type_covered(&rr->rrs, 0))
-                               ;
+                       const uint16_t type = kr_rrset_type_maysig(rr);
+                       const bool type_OK = rr->type == query->stype || type == query->stype
+                               || type == KNOT_RRTYPE_CNAME || type == KNOT_RRTYPE_DNAME;
+                               /* TODO: actually handle DNAMEs */
                        if (!type_OK || !knot_dname_is_equal(rr->owner, cname)) {
                                continue;
                        }
index e7f3a0f853d9c12f55d7c5518ec725e5a5ddbf43..263c517ca477a69b3832c784fe58fcc35cf07e72 100644 (file)
@@ -313,9 +313,7 @@ static int stash_authority(struct kr_request *req, knot_pkt_t *pkt, map_t *stash
 
                /* Skip NSEC3 RRs and their signatures.  We don't use them this way.
                 * They would be stored under the hashed name, etc. */
-               if (rr->type == KNOT_RRTYPE_NSEC3
-                   || (rr->type == KNOT_RRTYPE_RRSIG
-                       && knot_rrsig_type_covered(&rr->rrs, 0) == KNOT_RRTYPE_NSEC3)) {
+               if (kr_rrset_type_maysig(rr) == KNOT_RRTYPE_NSEC3) {
                    continue;
                }
 
index 0db488bff702a850efe29b45ff318ccdd72a9605..c528c6dd4079857836ae2ff2438de7a2da458e93 100644 (file)
@@ -429,11 +429,10 @@ int kr_rrmap_add(map_t *stash, const knot_rrset_t *rr, uint8_t rank, knot_mm_t *
        /* Stash key = {[1] flags, [1-255] owner, [5] type, [1] \x00 } */
        char key[KR_RRKEY_LEN];
        uint8_t extra_flags = 0;
-       uint16_t rrtype = rr->type;
+       uint16_t rrtype = kr_rrset_type_maysig(rr);
        /* Stash RRSIGs in a special cache, flag them and set type to its covering RR.
         * This way it the stash won't merge RRSIGs together. */
        if (rr->type == KNOT_RRTYPE_RRSIG) {
-               rrtype = knot_rrsig_type_covered(&rr->rrs, 0);
                extra_flags |= KEY_FLAG_RRSIG;
        }
        int ret = kr_rrkey(key, rr->owner, rrtype, rank);
index da87e64c5543758e8f680b1c5ba2b991347d20b1..59b1e3cfb477fea15ae96eed2b70a95c3fb8de08 100644 (file)
 #include <stdbool.h>
 #include <sys/time.h>
 #include <netinet/in.h>
+#include <libknot/libknot.h>
 #include <libknot/packet/pkt.h>
+#include <libknot/rrset.h>
+#include <libknot/rrtype/rrsig.h>
 #include "lib/generic/map.h"
 #include "lib/generic/array.h"
 #include "lib/defines.h"
@@ -240,3 +243,12 @@ char *kr_module_call(struct kr_context *ctx, const char *module, const char *pro
        memcpy(&x, swap_temp, sizeof(x)); \
        } while(0)
 
+/** Return the (covered) type of an nonempty RRset. */
+static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr)
+{
+       assert(rr && rr->rrs.rr_count && rr->rrs.data);
+       uint16_t type = rr->type;
+       if (type == KNOT_RRTYPE_RRSIG)
+               type = knot_rrsig_type_covered(&rr->rrs, 0);
+       return type;
+}