Commit 976eb76c authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

general: determine if node is apex from flags not parent ptr

parent 25b571de
...@@ -54,7 +54,7 @@ inline static void bitmap_add_node_rrsets(dnssec_nsec_bitmap_t *bitmap, ...@@ -54,7 +54,7 @@ inline static void bitmap_add_node_rrsets(dnssec_nsec_bitmap_t *bitmap,
const zone_node_t *node) const zone_node_t *node)
{ {
bool deleg = node->flags & NODE_FLAGS_DELEG; 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++) { for (int i = 0; i < node->rrset_count; i++) {
knot_rrset_t rr = node_rrset_at(node, i); knot_rrset_t rr = node_rrset_at(node, i);
if (deleg && (rr.type != KNOT_RRTYPE_NS && rr.type != KNOT_RRTYPE_DS)) { if (deleg && (rr.type != KNOT_RRTYPE_NS && rr.type != KNOT_RRTYPE_DS)) {
......
...@@ -698,7 +698,7 @@ static int nsec3_mark_empty(zone_node_t **node_p, void *data) ...@@ -698,7 +698,7 @@ static int nsec3_mark_empty(zone_node_t **node_p, void *data)
*/ */
node->flags |= NODE_FLAGS_EMPTY; node->flags |= NODE_FLAGS_EMPTY;
if (node->parent) { if (!(node->flags & NODE_FLAGS_APEX)) {
/* We must decrease the parent's children count, /* We must decrease the parent's children count,
* but only temporarily! It must be set back right after * but only temporarily! It must be set back right after
* the operation * the operation
......
...@@ -38,7 +38,7 @@ int adjust_cb_flags(zone_node_t *node, const zone_contents_t *zone) ...@@ -38,7 +38,7 @@ int adjust_cb_flags(zone_node_t *node, const zone_contents_t *zone)
node->flags |= NODE_FLAGS_DELEG; node->flags |= NODE_FLAGS_DELEG;
} else { } else {
// Default. // Default.
node->flags = NODE_FLAGS_AUTH; node->flags = NODE_FLAGS_AUTH | (node->flags & NODE_FLAGS_APEX);
} }
return KNOT_EOK; // always returns this value :) return KNOT_EOK; // always returns this value :)
......
...@@ -162,6 +162,7 @@ zone_contents_t *zone_contents_new(const knot_dname_t *apex_name) ...@@ -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) { if (zone_tree_insert(contents->nodes, contents->apex) != KNOT_EOK) {
goto cleanup; goto cleanup;
} }
contents->apex->flags |= NODE_FLAGS_APEX;
return contents; return contents;
......
...@@ -81,6 +81,8 @@ enum node_flags { ...@@ -81,6 +81,8 @@ enum node_flags {
NODE_FLAGS_WILDCARD_CHILD = 1 << 4, NODE_FLAGS_WILDCARD_CHILD = 1 << 4,
/*! \brief Is this NSEC3 node compatible with zone's NSEC3PARAMS ? */ /*! \brief Is this NSEC3 node compatible with zone's NSEC3PARAMS ? */
NODE_FLAGS_IN_NSEC3_CHAIN = 1 << 5, NODE_FLAGS_IN_NSEC3_CHAIN = 1 << 5,
/*! \brief Node is the zone Apex. */
NODE_FLAGS_APEX = 1 << 6,
}; };
/*! /*!
......
...@@ -1093,7 +1093,7 @@ static int check_dname(const zone_node_t *node, semchecks_data_t *data) ...@@ -1093,7 +1093,7 @@ static int check_dname(const zone_node_t *node, semchecks_data_t *data)
} }
/* RFC 6672 Section 2.3 Paragraph 3 */ /* 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)) { if (!is_apex && node_rrtype_exists(node, KNOT_RRTYPE_NS)) {
data->handler->fatal_error = true; data->handler->fatal_error = true;
data->handler->cb(data->handler, data->zone, node, data->handler->cb(data->handler, data->zone, node,
......
...@@ -154,7 +154,7 @@ void zone_tree_delete_empty(zone_tree_t *tree, zone_node_t *node) ...@@ -154,7 +154,7 @@ void zone_tree_delete_empty(zone_tree_t *tree, zone_node_t *node)
if (parent_node != NULL) { if (parent_node != NULL) {
parent_node->children--; parent_node->children--;
fix_wildcard_child(parent_node, node->owner); 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. // Recurse using the parent node, do not delete possibly empty parent.
zone_tree_delete_empty(tree, parent_node); zone_tree_delete_empty(tree, parent_node);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment