-/* 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
}
}
+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) {
{
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 */
}
}
- 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;
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);
}
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
* \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);
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;
}