val = conf_zone_get(conf, C_DNSSEC_SIGNING, zone->name);
bool dnssec_enable = conf_bool(&val), zu_from_zf_conts = false;
zone_update_t up = { 0 };
- bool ignore_dnssec = ((zf_from == ZONEFILE_LOAD_DIFF || zf_from == ZONEFILE_LOAD_DIFSE)
- && dnssec_enable);
+ bool do_diff = (zf_from == ZONEFILE_LOAD_DIFF || zf_from == ZONEFILE_LOAD_DIFSE);
+ bool ignore_dnssec = (do_diff && dnssec_enable);
// Create zone_update structure according to current state.
if (old_contents_exist) {
} else {
// compute ZF diff and if success, apply it
ret = zone_update_from_differences(&up, zone, zone->contents, zf_conts, UPDATE_INCREMENTAL, ignore_dnssec);
- zone_contents_deep_free(zf_conts);
- zf_conts = NULL;
}
} else {
if (journal_conts != NULL && zf_from != ZONEFILE_LOAD_WHOLE) {
// load zone-in-journal, compute ZF diff and if success, apply it
ret = zone_update_from_differences(&up, zone, journal_conts, zf_conts,
UPDATE_HYBRID, ignore_dnssec);
- zone_contents_deep_free(zf_conts);
- zf_conts = NULL;
if (ret == KNOT_ESEMCHECK || ret == KNOT_ERANGE) {
log_zone_warning(zone->name,
"zone file changed with SOA serial %s, "
uint32_t middle_serial = zone_contents_serial(up.new_cont);
- if ((zf_from == ZONEFILE_LOAD_DIFF || zf_from == ZONEFILE_LOAD_DIFSE) &&
- old_contents_exist && journal_conts == NULL) {
+ if (do_diff && old_contents_exist && journal_conts == NULL && dnssec_enable) {
ret = zone_update_start_extra(&up);
- printf("start extra %d %u\n", ret, up.flags);
if (ret != KNOT_EOK) {
zone_update_clear(&up);
goto cleanup;
log_zone_info(zone->name, "automatic SOA serial increment");
}
+ update->init_cont = new_cont;
return KNOT_EOK;
}
return ret;
}
- update->extra_ch.soa_from = node_create_rrset(update->new_cont->apex, KNOT_RRTYPE_SOA);
- if (update->extra_ch.soa_from == NULL) {
- return KNOT_ENOMEM;
- }
+ if (update->init_cont != NULL) {
+ ret = zone_update_increment_soa(update, conf());
+ if (ret != KNOT_EOK) {
+ return ret;
+ }
- ret = zone_update_increment_soa(update, conf());
- if (ret != KNOT_EOK) {
- return ret;
- }
+ ret = zone_contents_diff(update->init_cont, update->new_cont, &update->extra_ch, false);
+ if (ret != KNOT_EOK) {
+ return ret;
+ }
+ } else {
+ update->extra_ch.soa_from = node_create_rrset(update->new_cont->apex, KNOT_RRTYPE_SOA);
+ if (update->extra_ch.soa_from == NULL) {
+ return KNOT_ENOMEM;
+ }
- update->extra_ch.soa_to = node_create_rrset(update->new_cont->apex, KNOT_RRTYPE_SOA);
- if (update->extra_ch.soa_to == NULL) {
- return KNOT_ENOMEM;
+ ret = zone_update_increment_soa(update, conf());
+ if (ret != KNOT_EOK) {
+ return ret;
+ }
+
+ update->extra_ch.soa_to = node_create_rrset(update->new_cont->apex, KNOT_RRTYPE_SOA);
+ if (update->extra_ch.soa_to == NULL) {
+ return KNOT_ENOMEM;
+ }
}
update->flags |= UPDATE_EXTRA_CHSET;
changeset_clear(&update->extra_ch);
}
+ zone_contents_deep_free(update->init_cont);
+
if (update->flags & (UPDATE_FULL | UPDATE_HYBRID)) {
update_cleanup(update->a_ctx);
zone_contents_deep_free(update->new_cont);
zone_t *zone; /*!< Zone being updated. */
zone_contents_t *new_cont; /*!< New zone contents for full updates. */
changeset_t change; /*!< Changes we want to apply. */
+ zone_contents_t *init_cont; /*!< Exact contents of the zonefile. */
changeset_t extra_ch; /*!< Extra changeset to store just diff btwn zonefile and result. */
apply_ctx_t *a_ctx; /*!< Context for applying changesets. */
uint32_t flags; /*!< Zone update flags. */