Skip to content
Snippets Groups Projects
Commit ce3e186d authored by Daniel Salzman's avatar Daniel Salzman
Browse files

refresh: unify xfr_validate() interface

parent b3976c29
No related branches found
No related tags found
1 merge request!1234Apply mandatory zone semantic checks on control operations
......@@ -153,10 +153,12 @@ static time_t bootstrap_next(const zone_timers_t *timers)
return interval;
}
static int xfr_validate(zone_contents_t *zone, zone_tree_t *update_node_ptrs)
static int xfr_validate(zone_update_t *up)
{
zone_tree_t *node_ptrs = (up->flags & UPDATE_INCREMENTAL) ? up->a_ctx->node_ptrs : NULL;
// adjust_cb_nsec3_pointer not needed as we don't check DNSSEC here
int ret = zone_adjust_contents(zone, adjust_cb_flags, NULL, false, false, 1, update_node_ptrs);
int ret = zone_adjust_contents(up->new_cont, adjust_cb_flags, NULL, false, false, 1, node_ptrs);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -165,7 +167,7 @@ static int xfr_validate(zone_contents_t *zone, zone_tree_t *update_node_ptrs)
.cb = err_handler_logger
};
ret = sem_checks_process(zone, SEMCHECK_MANDATORY_ONLY, &handler, time(NULL));
ret = sem_checks_process(up->new_cont, SEMCHECK_MANDATORY_ONLY, &handler, time(NULL));
if (ret != KNOT_EOK) {
// error is logged by the error handler
return ret;
......@@ -253,11 +255,6 @@ static int axfr_finalize(struct refresh_data *data)
{
zone_contents_t *new_zone = data->axfr.zone;
int ret = xfr_validate(new_zone, NULL);
if (ret != KNOT_EOK) {
return ret;
}
conf_val_t val = conf_zone_get(data->conf, C_DNSSEC_SIGNING, data->zone->name);
bool dnssec_enable = conf_bool(&val);
uint32_t old_serial = zone_contents_serial(data->zone->contents), master_serial = 0;
......@@ -268,14 +265,19 @@ static int axfr_finalize(struct refresh_data *data)
}
zone_update_t up = { 0 };
ret = zone_update_from_contents(&up, data->zone, new_zone, UPDATE_FULL);
int ret = zone_update_from_contents(&up, data->zone, new_zone, UPDATE_FULL);
if (ret != KNOT_EOK) {
return ret;
}
// Seized by zone_update. Don't free the contents again in axfr_cleanup.
data->axfr.zone = NULL;
ret = xfr_validate(&up);
if (ret != KNOT_EOK) {
zone_update_clear(&up);
return ret;
}
if (dnssec_enable) {
zone_sign_reschedule_t resch = { 0 };
ret = knot_dnssec_zone_sign(&up, ZONE_SIGN_KEEP_SERIAL, KEY_ROLL_ALLOW_ALL, 0, &resch);
......@@ -527,7 +529,7 @@ static int ixfr_finalize(struct refresh_data *data)
}
}
ret = xfr_validate(up.new_cont, up.a_ctx->node_ptrs);
ret = xfr_validate(&up);
if (ret != KNOT_EOK) {
zone_update_clear(&up);
return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment