Commit 1ae4fc15 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

adjusting: adjusting nsec3_wildcard pointers only incrementally

parent 82a944c1
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -271,6 +271,20 @@ uint32_t zone_update_current_serial(zone_update_t *update)
}
}
static bool zone_update_changed_nsec3param(const zone_update_t *update)
{
if (update->zone->contents == NULL) {
return true;
}
dnssec_nsec3_params_t *orig = &update->zone->contents->nsec3_params;
dnssec_nsec3_params_t *upd = &update->new_cont->nsec3_params;
return (orig->algorithm == upd->algorithm &&
orig->iterations == upd->iterations &&
orig->flags == upd->flags &&
dnssec_binary_cmp(&orig->salt, &upd->salt) == 0);
}
const knot_rdataset_t *zone_update_from(zone_update_t *update)
{
if (update == NULL) {
......@@ -602,7 +616,6 @@ static int commit_incremental(conf_t *conf, zone_update_t *update)
{
assert(update);
zone_contents_t *new_contents = update->new_cont;
int ret = KNOT_EOK;
if (zone_update_to(update) == NULL && !changeset_empty(&update->change)) {
/* No SOA in the update, create one according to the current policy */
......@@ -613,7 +626,11 @@ static int commit_incremental(conf_t *conf, zone_update_t *update)
}
}
ret = zone_adjust_full(new_contents);
if (zone_update_changed_nsec3param(update)) {
ret = zone_adjust_full(update->new_cont);
} else {
ret = zone_adjust_incremental_update(update);
}
if (ret != KNOT_EOK) {
zone_update_clear(update);
return ret;
......
......@@ -234,6 +234,15 @@ int adjust_cb_nsec3_and_additionals(zone_node_t *node, const zone_contents_t *zo
return ret;
}
static int adjust_cb_nsec3_and_additionals2(zone_node_t *node, const zone_contents_t *zone)
{
int ret = adjust_cb_point_to_nsec3(node, zone);
if (ret == KNOT_EOK) {
ret = adjust_cb_additionals(node, zone);
}
return ret;
}
int adjust_cb_void(zone_node_t *node, const zone_contents_t *zone)
{
UNUSED(node);
......@@ -394,3 +403,15 @@ int zone_adjust_full(zone_contents_t *zone)
}
return ret;
}
int zone_adjust_incremental_update(zone_update_t *update)
{
int ret = zone_adjust_contents(update->new_cont, adjust_cb_flags, adjust_cb_nsec3_flags, true);
if (ret == KNOT_EOK) {
ret = zone_adjust_contents(update->new_cont, adjust_cb_nsec3_and_additionals2, NULL, false);
}
if (ret == KNOT_EOK) {
ret = zone_adjust_update(update, adjust_cb_wildcard_nsec3, NULL);
}
return ret;
}
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -94,3 +94,12 @@ int zone_adjust_update(zone_update_t *update, adjust_cb_t nodes_cb, adjust_cb_t
* \return KNOT_E*
*/
int zone_adjust_full(zone_contents_t *zone);
/*!
* \brief Do a generally approved adjust after incremental update.
*
* \param update Zone update to be adjusted incrementally.
*
* \return KNOT_E*
*/
int zone_adjust_incremental_update(zone_update_t *update);
......@@ -155,7 +155,9 @@ zone_node_t *node_shallow_copy(const zone_node_t *src, knot_mm_t *mm)
dst->rrset_count = src->rrset_count;
size_t rrlen = sizeof(struct rr_data) * src->rrset_count;
dst->rrs = mm_alloc(mm, rrlen);
if (dst->rrs == NULL) {
dst->nsec3_wildcard_name = knot_dname_copy(src->nsec3_wildcard_name, NULL);
if (dst->rrs == NULL ||
(src->nsec3_wildcard_name != NULL && dst->nsec3_wildcard_name == NULL)) {
node_free(dst, mm);
return NULL;
}
......
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