From: Libor Peltan Date: Mon, 4 Feb 2019 15:41:20 +0000 (+0100) Subject: general: determine if node is apex from flags not parent ptr X-Git-Tag: v2.9.0~286^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=976eb76c23dd3845cf7ea66c8830e637704e7d7d;p=thirdparty%2Fknot-dns.git general: determine if node is apex from flags not parent ptr --- diff --git a/src/knot/dnssec/nsec-chain.h b/src/knot/dnssec/nsec-chain.h index b0c7fa7640..dfdbeb55bf 100644 --- a/src/knot/dnssec/nsec-chain.h +++ b/src/knot/dnssec/nsec-chain.h @@ -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)) { diff --git a/src/knot/dnssec/nsec3-chain.c b/src/knot/dnssec/nsec3-chain.c index fe706af0c3..1012d2307b 100644 --- a/src/knot/dnssec/nsec3-chain.c +++ b/src/knot/dnssec/nsec3-chain.c @@ -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 diff --git a/src/knot/zone/adjust.c b/src/knot/zone/adjust.c index 0a08e56aec..6072142aa8 100644 --- a/src/knot/zone/adjust.c +++ b/src/knot/zone/adjust.c @@ -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 :) diff --git a/src/knot/zone/contents.c b/src/knot/zone/contents.c index 48eea2f387..3f8b65014a 100644 --- a/src/knot/zone/contents.c +++ b/src/knot/zone/contents.c @@ -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; diff --git a/src/knot/zone/node.h b/src/knot/zone/node.h index cb19f475de..8a77bae6e4 100644 --- a/src/knot/zone/node.h +++ b/src/knot/zone/node.h @@ -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, }; /*! diff --git a/src/knot/zone/semantic-check.c b/src/knot/zone/semantic-check.c index 2ab3a83dbf..eda497dc51 100644 --- a/src/knot/zone/semantic-check.c +++ b/src/knot/zone/semantic-check.c @@ -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, diff --git a/src/knot/zone/zone-tree.c b/src/knot/zone/zone-tree.c index 486853bfb4..85aa4c762b 100644 --- a/src/knot/zone/zone-tree.c +++ b/src/knot/zone/zone-tree.c @@ -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); }