From: Libor Peltan Date: Tue, 5 Feb 2019 17:01:11 +0000 (+0100) Subject: adjusting: adjusting nsec3_wildcard pointers only incrementally X-Git-Tag: v2.8.0~72^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ae4fc15f166e2403870cc58cc41518ed23daa05;p=thirdparty%2Fknot-dns.git adjusting: adjusting nsec3_wildcard pointers only incrementally --- diff --git a/src/knot/updates/zone-update.c b/src/knot/updates/zone-update.c index 4ebd4b55d0..702a11d7ea 100644 --- a/src/knot/updates/zone-update.c +++ b/src/knot/updates/zone-update.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. +/* Copyright (C) 2019 CZ.NIC, z.s.p.o. 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; diff --git a/src/knot/zone/adjust.c b/src/knot/zone/adjust.c index c1546d5f8b..6d9f4c7251 100644 --- a/src/knot/zone/adjust.c +++ b/src/knot/zone/adjust.c @@ -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; +} diff --git a/src/knot/zone/adjust.h b/src/knot/zone/adjust.h index 18e7af1b11..b25671598c 100644 --- a/src/knot/zone/adjust.h +++ b/src/knot/zone/adjust.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. +/* Copyright (C) 2019 CZ.NIC, z.s.p.o. 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); diff --git a/src/knot/zone/node.c b/src/knot/zone/node.c index 45ccb23778..8456fd1249 100644 --- a/src/knot/zone/node.c +++ b/src/knot/zone/node.c @@ -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; }