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)) {
*/
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
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 :)
if (zone_tree_insert(contents->nodes, contents->apex) != KNOT_EOK) {
goto cleanup;
}
+ contents->apex->flags |= NODE_FLAGS_APEX;
return contents;
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,
};
/*!
}
/* 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,
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);
}