Commit 615a386a authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'fix_load_nsec3param' into 'master'

fix: load NSEC3PARAM before comparing it

See merge request !997
parents 73d901ef ce0b4e0d
......@@ -624,6 +624,12 @@ static int commit_incremental(conf_t *conf, zone_update_t *update)
}
}
ret = zone_contents_load_nsec3param(update->new_cont);
if (ret != KNOT_EOK) {
zone_update_clear(update);
return ret;
}
if (zone_update_changed_nsec3param(update)) {
ret = zone_adjust_full(update->new_cont);
} else {
......
......@@ -330,41 +330,9 @@ static int zone_adjust_tree(zone_tree_t *tree, const zone_contents_t *zone, adju
return KNOT_EOK;
}
static int load_nsec3param(zone_contents_t *contents)
{
assert(contents);
assert(contents->apex);
const knot_rdataset_t *rrs = NULL;
rrs = node_rdataset(contents->apex, KNOT_RRTYPE_NSEC3PARAM);
if (rrs == NULL) {
dnssec_nsec3_params_free(&contents->nsec3_params);
return KNOT_EOK;
}
if (rrs->count < 1) {
return KNOT_EINVAL;
}
dnssec_binary_t rdata = {
.size = rrs->rdata->len,
.data = rrs->rdata->data,
};
dnssec_nsec3_params_t new_params = { 0 };
int r = dnssec_nsec3_params_from_rdata(&new_params, &rdata);
if (r != DNSSEC_EOK) {
return KNOT_EMALF;
}
dnssec_nsec3_params_free(&contents->nsec3_params);
contents->nsec3_params = new_params;
return KNOT_EOK;
}
int zone_adjust_contents(zone_contents_t *zone, adjust_cb_t nodes_cb, adjust_cb_t nsec3_cb, bool measure_size)
{
int ret = load_nsec3param(zone);
int ret = zone_contents_load_nsec3param(zone);
if (ret != KNOT_EOK) {
log_zone_error(zone->apex->owner,
"failed to load NSEC3 parameters (%s)",
......
......@@ -767,6 +767,39 @@ void zone_contents_set_soa_serial(zone_contents_t *zone, uint32_t new_serial)
}
}
int zone_contents_load_nsec3param(zone_contents_t *contents)
{
if (contents == NULL || contents->apex == NULL) {
return KNOT_EINVAL;
}
const knot_rdataset_t *rrs = NULL;
rrs = node_rdataset(contents->apex, KNOT_RRTYPE_NSEC3PARAM);
if (rrs == NULL) {
dnssec_nsec3_params_free(&contents->nsec3_params);
return KNOT_EOK;
}
if (rrs->count != 1) {
return KNOT_EINVAL;
}
dnssec_binary_t rdata = {
.size = rrs->rdata->len,
.data = rrs->rdata->data,
};
dnssec_nsec3_params_t new_params = { 0 };
int r = dnssec_nsec3_params_from_rdata(&new_params, &rdata);
if (r != DNSSEC_EOK) {
return KNOT_EMALF;
}
dnssec_nsec3_params_free(&contents->nsec3_params);
contents->nsec3_params = new_params;
return KNOT_EOK;
}
bool zone_contents_is_empty(const zone_contents_t *zone)
{
if (zone == NULL) {
......
......@@ -283,6 +283,11 @@ uint32_t zone_contents_serial(const zone_contents_t *zone);
*/
void zone_contents_set_soa_serial(zone_contents_t *zone, uint32_t new_serial);
/*!
* \brief Load parameters from NSEC3PARAM record into contents->nsec3param structure.
*/
int zone_contents_load_nsec3param(zone_contents_t *contents);
/*!
* \brief Return true if zone is empty.
*/
......
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