* but only temporarily! It must be set back right after
* the operation
*/
- node->parent->children--;
+ node_parent(node)->children--;
/* Recurse using the parent node */
- return nsec3_mark_empty(node->parent, data);
+ return nsec3_mark_empty(node_parent(node), data);
}
}
/* If node was marked as empty, increase its parent's children
* count.
*/
- node->parent->children++;
+ node_parent(node)->children++;
/* Clear the 'empty' flag. */
node->flags &= ~NODE_FLAGS_EMPTY;
}
return NULL;
}
-static bool shall_sign_rr(const knot_rrset_t *rr, const knot_pkt_t *pkt)
+static bool shall_sign_rr(const knot_rrset_t *rr, const knot_pkt_t *pkt, knotd_qdata_t *qdata)
{
if (pkt->current == KNOT_ADDITIONAL) {
glue_t *g = find_glue_for(rr, pkt);
assert(g); // finds actually the node which is rr in
- return !(g->node->flags & NODE_FLAGS_NONAUTH);
+ const zone_node_t *gn = glue_node(g, qdata->extra->node);
+ return !(gn->flags & NODE_FLAGS_NONAUTH);
} else {
return !is_deleg(pkt) || rr->type == KNOT_RRTYPE_NSEC;
}
uint16_t count_unsigned = section->count;
for (int i = 0; i < count_unsigned; i++) {
const knot_rrset_t *rr = knot_pkt_rr(section, i);
- if (!shall_sign_rr(rr, pkt)) {
+ if (!shall_sign_rr(rr, pkt, qdata)) {
continue;
}
{
/* Find closest delegation point. */
while (!(qdata->extra->node->flags & NODE_FLAGS_DELEG)) {
- qdata->extra->node = qdata->extra->node->parent;
+ qdata->extra->node = node_parent(qdata->extra->node);
}
/* Insert NS record. */
uint16_t hint = knot_compr_hint(info, KNOT_COMPR_HINT_RDATA +
glue->ns_pos);
- knot_rrset_t rrsigs = node_rrset(glue->node, KNOT_RRTYPE_RRSIG);
+ knot_rrset_t rrsigs = node_rrset(glue_node(glue, qdata->extra->node), KNOT_RRTYPE_RRSIG);
for (int k = 0; k < ar_type_count; ++k) {
knot_rrset_t rrset = node_rrset(glue->node, ar_type_list[k]);
if (knot_rrset_empty(&rrset)) {
/* Look up an authoritative encloser or its parent. */
const zone_node_t *node = qdata->extra->encloser;
while (node->rrset_count == 0 || node->flags & NODE_FLAGS_NONAUTH) {
- node = node->parent;
+ node = node_parent(node);
assert(node);
}
assert(previous);
while (!node_in_nsec(previous)) {
- previous = previous->prev;
+ previous = node_prev(previous);
assert(previous);
}
assert(closest);
while (!node_in_nsec3(closest)) {
- closest = closest->parent;
+ closest = node_parent(closest);
assert(closest);
}
knotd_qdata_t *qdata,
knot_pkt_t *resp)
{
- const zone_node_t *cpe = nsec3_encloser(wildcard->parent);
+ const zone_node_t *cpe = nsec3_encloser(node_parent(wildcard));
return put_nsec3_next_closer(cpe, qname, zone, qdata, resp);
}
int adjust_cb_flags(zone_node_t *node, const zone_contents_t *zone)
{
+ zone_node_t *parent = node_parent(node);
+
// check if this node is not a wildcard child of its parent
if (knot_dname_is_wildcard(node->owner)) {
- assert(node->parent != NULL);
- node->parent->flags |= NODE_FLAGS_WILDCARD_CHILD;
+ parent->flags |= NODE_FLAGS_WILDCARD_CHILD;
}
// set flags (delegation point, non-authoritative)
- if (node->parent &&
- (node->parent->flags & NODE_FLAGS_DELEG ||
- node->parent->flags & NODE_FLAGS_NONAUTH)) {
+ if (parent && (parent->flags & NODE_FLAGS_DELEG || parent->flags & NODE_FLAGS_NONAUTH)) {
node->flags |= NODE_FLAGS_NONAUTH;
} else if (node_rrtype_exists(node, KNOT_RRTYPE_NS) && node != zone->apex) {
node->flags |= NODE_FLAGS_DELEG;
// set the found parent (in the zone) as the parent of the last
// inserted node
- assert(node->parent == NULL);
node_set_parent(node, next_node);
}
node = prev;
size_t matched_labels = knot_dname_matched_labels(node->owner, name);
while (matched_labels < knot_dname_labels(node->owner, NULL)) {
- node = node->parent;
+ node = node_parent(node);
assert(node);
}
// set the previous node of the found node
assert(match);
assert(*nsec3_node != NULL);
- *nsec3_previous = (*nsec3_node)->prev;
+ *nsec3_previous = node_prev(*nsec3_node);
} else {
*nsec3_previous = prev;
}
// The previous may be from wrong NSEC3 chain. Search for previous from the right chain.
const zone_node_t *original_prev = *nsec3_previous;
while (!((*nsec3_previous)->flags & NODE_FLAGS_IN_NSEC3_CHAIN)) {
- *nsec3_previous = (*nsec3_previous)->prev;
+ *nsec3_previous = node_prev(*nsec3_previous);
if (*nsec3_previous == original_prev || *nsec3_previous == NULL) {
// cycle
*nsec3_previous = NULL;
}
}
+zone_node_t *node_parent(const zone_node_t *node)
+{
+ return node->parent;
+}
+
+zone_node_t *node_prev(const zone_node_t *node)
+{
+ return node->prev;
+}
+
+const zone_node_t *glue_node(const glue_t *glue, const zone_node_t *another_zone_node)
+{
+ UNUSED(another_zone_node);
+ return glue->node;
+}
+
bool node_rrtype_is_signed(const zone_node_t *node, uint16_t type)
{
if (node == NULL) {
*/
void node_set_parent(zone_node_t *node, zone_node_t *parent);
+/*!
+ * \brief Returns parent node (fixing bi-node issue) of given node.
+ */
+zone_node_t *node_parent(const zone_node_t *node);
+
+/*!
+ * \brief Returns previous (lexicographically in same zone tree) node (fixing bi-node issue) of given node.
+ */
+zone_node_t *node_prev(const zone_node_t *node);
+
+/*!
+ * \brief Return node referenced by a glue.
+ *
+ * \param glue Glue in question.
+ * \param another_zone_node Another node from the same zone.
+ *
+ * \return Glue node.
+ */
+const zone_node_t *glue_node(const glue_t *glue, const zone_node_t *another_zone_node);
+
/*!
* \brief Checks whether node contains any RRSIG for given type.
*
const zone_node_t *next_nsec3 = zone_contents_find_nsec3_node(data->zone,
next_dname);
- if (next_nsec3 == NULL || next_nsec3->prev != node->nsec3_node) {
+ if (next_nsec3 == NULL || node_prev(next_nsec3) != node->nsec3_node) {
uint8_t *next = NULL;
int32_t next_len = base32hex_encode_alloc(next_dname_str,
next_dname_str_size,
int exact_match = 0;
if (ret == KNOT_EOK) {
if (fval != NULL) {
- *previous = (*found)->prev;
+ *previous = node_prev(*found);
}
exact_match = 1;
} else if (ret == 1) {
return ret;
}
*previous = zone_tree_it_val(&it); /* leftmost */
- *previous = (*previous)->prev; /* rightmost */
+ *previous = node_prev(*previous); /* rightmost */
*found = NULL;
zone_tree_it_free(&it);
}
}
if (node->rrset_count == 0 && node->children == 0) {
- zone_node_t *parent_node = node->parent;
+ zone_node_t *parent_node = node_parent(node);
if (parent_node != NULL) {
parent_node->children--;
fix_wildcard_child(parent_node, node->owner);
zone_node_t *parent = node_new(dummy_owner, NULL);
assert(parent);
node_set_parent(node, parent);
- ok(node->parent == parent && parent->children == 1, "Node: set parent.");
+ ok(node_parent(node) == parent && parent->children == 1, "Node: set parent.");
node_free(parent, NULL);