Commit 4830b7ce authored by Marek Vavrusa's avatar Marek Vavrusa

Discover wildcard-covered additional records for affected nodes.

This requires an additional passthrough of the adjusted nodes
and may pose a performance penalty in the future.
If that need arises, we could sort it out in a different way.
parent 7e339168
......@@ -250,7 +250,7 @@ static int put_additional(knot_pkt_t *pkt, const knot_rrset_t *rr, knot_rrinfo_t
static const uint16_t ar_type_list[] = {KNOT_RRTYPE_A, KNOT_RRTYPE_AAAA};
int ret = KNOT_EOK;
uint32_t flags = KNOT_PF_NOTRUNC;
uint32_t flags = KNOT_PF_NOTRUNC|KNOT_PF_CHECKDUP;
uint16_t hint = COMPR_HINT_NONE;
const knot_node_t *node = NULL;
const knot_rrset_t *additional = NULL;
......@@ -265,11 +265,6 @@ static int put_additional(knot_pkt_t *pkt, const knot_rrset_t *rr, knot_rrinfo_t
break;
}
/* \note Not processing wildcards as it's only optional. */
if (knot_dname_is_wildcard(node->owner)) {
continue;
}
for (uint16_t k = 0; k < AR_TYPE_COUNT; ++k) {
additional = knot_node_rrset(node, ar_type_list[k]);
if (additional == NULL) {
......
......@@ -172,7 +172,7 @@ static int discover_additionals(knot_rrset_t *rr, knot_zone_contents_t *zone)
for (uint16_t i = 0; i < rdcount; i++) {
/* Resolve and connect. */
/* Try to find node for the dname in the RDATA. */
dname = knot_rdata_name(rr, i);
knot_zone_contents_find_dname(zone, dname, &node, &encloser, &prev);
if (node == NULL && encloser && encloser->wildcard_child) {
......@@ -263,17 +263,6 @@ static int knot_zone_contents_adjust_normal_node(knot_node_t **tnode,
knot_dname_free(&nsec3_name);
/* Lookup additional records for specific nodes. */
knot_rrset_t **rrset = node->rrset_tree;
for(uint16_t i = 0; i < node->rrset_count; ++i) {
if (rrset_additional_needed(rrset[i]->type)) {
ret = discover_additionals(rrset[i], args->zone);
if (ret != KNOT_EOK) {
break;
}
}
}
return ret;
}
......@@ -311,6 +300,31 @@ static int knot_zone_contents_adjust_nsec3_node(knot_node_t **tnode,
return KNOT_EOK;
}
/*! \brief Discover additional records for affected nodes. */
static int knot_zone_contents_discover_additional(knot_node_t **tnode, void *data)
{
assert(data != NULL);
assert(tnode != NULL);
int ret = KNOT_EOK;
knot_zone_adjust_arg_t *args = (knot_zone_adjust_arg_t *)data;
knot_node_t *node = *tnode;
knot_rrset_t **rrset = node->rrset_tree;
/* Lookup additional records for specific nodes. */
for(uint16_t i = 0; i < node->rrset_count; ++i) {
if (rrset_additional_needed(rrset[i]->type)) {
ret = discover_additionals(rrset[i], args->zone);
if (ret != KNOT_EOK) {
break;
}
}
}
return ret;
}
/*----------------------------------------------------------------------------*/
/*!
* \brief Tries to find the given domain name in the zone tree.
......@@ -1357,6 +1371,16 @@ int knot_zone_contents_adjust(knot_zone_contents_t *zone,
assert(zone->apex == adjust_arg.first_node);
/* Discover additional records.
* \note This MUST be done after node adjusting because it needs to
* do full lookup to see through wildcards. */
result = knot_zone_contents_adjust_nodes(zone->nodes, &adjust_arg,
knot_zone_contents_discover_additional);
if (result != KNOT_EOK) {
return result;
}
return KNOT_EOK;
}
......
......@@ -88,3 +88,7 @@ sub.*.wildcard A 6.7.8.9
; CNAME loop
*.loop-entry CNAME jump.loop-target
*.loop-target CNAME jump.loop-entry
; MX record with name leading to wildcard-covered additional record
mx-additional MX 10 jump.wildcard-additional
*.wildcard-additional A 1.2.3.4
......@@ -187,6 +187,10 @@ resp.cmp(bind)
resp = knot.dig("test.loop-entry.flags", "A", udp=True)
resp.cmp(bind)
# Wildcard-covered additional record discovery
resp = knot.dig("mx-additional.flags", "MX", udp=True)
resp.cmp(bind)
''' Varied case tests. '''
# Negative (case preservation in question)
......
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