]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
adjusting: adjusting nsec3_wildcard pointers only incrementally
authorLibor Peltan <libor.peltan@nic.cz>
Tue, 5 Feb 2019 17:01:11 +0000 (18:01 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 6 Feb 2019 16:02:01 +0000 (17:02 +0100)
src/knot/updates/zone-update.c
src/knot/zone/adjust.c
src/knot/zone/adjust.h
src/knot/zone/node.c

index 4ebd4b55d03a1e00e4d0a151cd5bdb6aec60c08f..702a11d7eafcbab20e7a3d583737f7cfa4f66953 100644 (file)
@@ -1,4 +1,4 @@
-/*  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;
index c1546d5f8b018b83d481ea1248579a1a91661eb8..6d9f4c72511b13cfa92a82100b6bfa5605bedfc4 100644 (file)
@@ -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;
+}
index 18e7af1b115830f897dee6f2ffc96fa8ffa19841..b25671598cdd8ec2c31f3d5840e9e97c1307863f 100644 (file)
@@ -1,4 +1,4 @@
-/*  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);
index 45ccb2377849924d93bde5b807ac7f60e6c295b1..8456fd12493731705c18378ca266624d542610ba 100644 (file)
@@ -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;
        }