]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
general: determine if node is apex from flags not parent ptr
authorLibor Peltan <libor.peltan@nic.cz>
Mon, 4 Feb 2019 15:41:20 +0000 (16:41 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Fri, 26 Apr 2019 12:39:58 +0000 (14:39 +0200)
src/knot/dnssec/nsec-chain.h
src/knot/dnssec/nsec3-chain.c
src/knot/zone/adjust.c
src/knot/zone/contents.c
src/knot/zone/node.h
src/knot/zone/semantic-check.c
src/knot/zone/zone-tree.c

index b0c7fa7640821b98622515c7d697820d730d4e0c..dfdbeb55bf507fba75e2710bb2df6c37d9e532a1 100644 (file)
@@ -54,7 +54,7 @@ inline static void bitmap_add_node_rrsets(dnssec_nsec_bitmap_t *bitmap,
                                           const zone_node_t *node)
 {
        bool deleg = node->flags & NODE_FLAGS_DELEG;
-       bool apex = node->parent == NULL;
+       bool apex = node->flags & NODE_FLAGS_APEX;
        for (int i = 0; i < node->rrset_count; i++) {
                knot_rrset_t rr = node_rrset_at(node, i);
                if (deleg && (rr.type != KNOT_RRTYPE_NS && rr.type != KNOT_RRTYPE_DS)) {
index fe706af0c3b7ed61036fd148f1822ec61358041a..1012d2307b43e575b54415f48ebab0ba3a9a3999 100644 (file)
@@ -698,7 +698,7 @@ static int nsec3_mark_empty(zone_node_t **node_p, void *data)
                 */
                node->flags |= NODE_FLAGS_EMPTY;
 
-               if (node->parent) {
+               if (!(node->flags & NODE_FLAGS_APEX)) {
                        /* We must decrease the parent's children count,
                         * but only temporarily! It must be set back right after
                         * the operation
index 0a08e56aec2d278cdbcb646f91929057ea751a7e..6072142aa83acd2467061b3f1e8e217462e00460 100644 (file)
@@ -38,7 +38,7 @@ int adjust_cb_flags(zone_node_t *node, const zone_contents_t *zone)
                node->flags |= NODE_FLAGS_DELEG;
        } else {
                // Default.
-               node->flags = NODE_FLAGS_AUTH;
+               node->flags = NODE_FLAGS_AUTH | (node->flags & NODE_FLAGS_APEX);
        }
 
        return KNOT_EOK; // always returns this value :)
index 48eea2f3878e7e1170b6ba797123a8bbc356e491..3f8b65014a3806a63e4a1541a18dc033bb20a943 100644 (file)
@@ -162,6 +162,7 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name)
        if (zone_tree_insert(contents->nodes, contents->apex) != KNOT_EOK) {
                goto cleanup;
        }
+       contents->apex->flags |= NODE_FLAGS_APEX;
 
        return contents;
 
index cb19f475de35496557e432abbf17450d41b37c60..8a77bae6e424ee0ab333ba45f7c82f12222adce9 100644 (file)
@@ -81,6 +81,8 @@ enum node_flags {
        NODE_FLAGS_WILDCARD_CHILD =  1 << 4,
        /*! \brief Is this NSEC3 node compatible with zone's NSEC3PARAMS ? */
        NODE_FLAGS_IN_NSEC3_CHAIN =  1 << 5,
+       /*! \brief Node is the zone Apex. */
+       NODE_FLAGS_APEX =            1 << 6,
 };
 
 /*!
index 2ab3a83dbf91aa3a510414b8eceabe8219844214..eda497dc51be0bacfd468efe170e5c055fc5bec8 100644 (file)
@@ -1093,7 +1093,7 @@ static int check_dname(const zone_node_t *node, semchecks_data_t *data)
        }
 
        /* RFC 6672 Section 2.3 Paragraph 3 */
-       bool is_apex = (node->parent == NULL);
+       bool is_apex = (node->flags & NODE_FLAGS_APEX);
        if (!is_apex && node_rrtype_exists(node, KNOT_RRTYPE_NS)) {
                data->handler->fatal_error = true;
                data->handler->cb(data->handler, data->zone, node,
index 486853bfb41ca01fa1052a4833818312b33f568b..85aa4c762bf1a4dc508a939feed0ebd27e5a10cb 100644 (file)
@@ -154,7 +154,7 @@ void zone_tree_delete_empty(zone_tree_t *tree, zone_node_t *node)
                if (parent_node != NULL) {
                        parent_node->children--;
                        fix_wildcard_child(parent_node, node->owner);
-                       if (parent_node->parent != NULL) { /* Is not apex */
+                       if (!(parent_node->flags & NODE_FLAGS_APEX)) { /* Is not apex */
                                // Recurse using the parent node, do not delete possibly empty parent.
                                zone_tree_delete_empty(tree, parent_node);
                        }