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,
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)) {
......
......@@ -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
......
......@@ -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 :)
......
......@@ -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;
......
......@@ -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,
};
/*!
......
......@@ -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,
......
......@@ -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);
}
......
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