Commit 335bdb7c authored by Jan Kadlec's avatar Jan Kadlec

zone-events: ixfr: better logging, state switching, merged in and out

contexts.

- Also removed knot_ from changesets
parent 93b6a42a
...@@ -142,8 +142,8 @@ static int connect_nsec_nodes(zone_node_t *a, zone_node_t *b, ...@@ -142,8 +142,8 @@ static int connect_nsec_nodes(zone_node_t *a, zone_node_t *b,
dbg_dnssec_detail("Adding new NSEC to changeset.\n"); dbg_dnssec_detail("Adding new NSEC to changeset.\n");
// Add new NSEC to the changeset (no matter if old was removed) // Add new NSEC to the changeset (no matter if old was removed)
return knot_changeset_add_rrset(data->changeset, new_nsec, return changeset_add_rrset(data->changeset, new_nsec,
KNOT_CHANGESET_ADD); CHANGESET_ADD);
} }
/* - API - iterations ------------------------------------------------------- */ /* - API - iterations ------------------------------------------------------- */
...@@ -205,7 +205,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes, ...@@ -205,7 +205,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes,
* \brief Add entry for removed NSEC to the changeset. * \brief Add entry for removed NSEC to the changeset.
*/ */
int knot_nsec_changeset_remove(const zone_node_t *n, int knot_nsec_changeset_remove(const zone_node_t *n,
knot_changeset_t *changeset) changeset_t *changeset)
{ {
if (changeset == NULL) { if (changeset == NULL) {
return KNOT_EINVAL; return KNOT_EINVAL;
...@@ -219,8 +219,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n, ...@@ -219,8 +219,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n,
} }
if (nsec) { if (nsec) {
// update changeset // update changeset
result = knot_changeset_add_rrset(changeset, nsec, result = changeset_add_rrset(changeset, nsec,
KNOT_CHANGESET_REMOVE); CHANGESET_REMOVE);
if (result != KNOT_EOK) { if (result != KNOT_EOK) {
knot_rrset_free(&nsec, NULL); knot_rrset_free(&nsec, NULL);
return result; return result;
...@@ -253,8 +253,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n, ...@@ -253,8 +253,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n,
} }
// store RRSIG // store RRSIG
result = knot_changeset_add_rrset(changeset, synth_rrsigs, result = changeset_add_rrset(changeset, synth_rrsigs,
KNOT_CHANGESET_REMOVE); CHANGESET_REMOVE);
if (result != KNOT_EOK) { if (result != KNOT_EOK) {
knot_rrset_free(&synth_rrsigs, NULL); knot_rrset_free(&synth_rrsigs, NULL);
return result; return result;
...@@ -288,7 +288,7 @@ bool knot_nsec_empty_nsec_and_rrsigs_in_node(const zone_node_t *n) ...@@ -288,7 +288,7 @@ bool knot_nsec_empty_nsec_and_rrsigs_in_node(const zone_node_t *n)
* \brief Create new NSEC chain, add differences from current into a changeset. * \brief Create new NSEC chain, add differences from current into a changeset.
*/ */
int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl, int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset) changeset_t *changeset)
{ {
assert(zone); assert(zone);
assert(zone->nodes); assert(zone->nodes);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
*/ */
typedef struct { typedef struct {
uint32_t ttl; // TTL for NSEC(3) records uint32_t ttl; // TTL for NSEC(3) records
knot_changeset_t *changeset; // Changeset for NSEC(3) changes changeset_t *changeset; // Changeset for NSEC(3) changes
const zone_contents_t *zone; // Updated zone const zone_contents_t *zone; // Updated zone
} nsec_chain_iterate_data_t; } nsec_chain_iterate_data_t;
...@@ -96,7 +96,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes, ...@@ -96,7 +96,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes,
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_nsec_changeset_remove(const zone_node_t *n, int knot_nsec_changeset_remove(const zone_node_t *n,
knot_changeset_t *changeset); changeset_t *changeset);
/*! /*!
* \brief Checks whether the node is empty or eventually contains only NSEC and * \brief Checks whether the node is empty or eventually contains only NSEC and
...@@ -119,6 +119,6 @@ bool knot_nsec_empty_nsec_and_rrsigs_in_node(const zone_node_t *n); ...@@ -119,6 +119,6 @@ bool knot_nsec_empty_nsec_and_rrsigs_in_node(const zone_node_t *n);
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl, int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset); changeset_t *changeset);
#endif // _KNOT_DNSSEC_NSEC_CHAIN_FIX_H_ #endif // _KNOT_DNSSEC_NSEC_CHAIN_FIX_H_
...@@ -415,7 +415,7 @@ static int connect_nsec3_nodes(zone_node_t *a, zone_node_t *b, ...@@ -415,7 +415,7 @@ static int connect_nsec3_nodes(zone_node_t *a, zone_node_t *b,
*/ */
static int create_nsec3_nodes(const zone_contents_t *zone, uint32_t ttl, static int create_nsec3_nodes(const zone_contents_t *zone, uint32_t ttl,
knot_zone_tree_t *nsec3_nodes, knot_zone_tree_t *nsec3_nodes,
knot_changeset_t *chgset) changeset_t *chgset)
{ {
assert(zone); assert(zone);
assert(nsec3_nodes); assert(nsec3_nodes);
...@@ -583,7 +583,7 @@ static void reset_nodes(const zone_contents_t *zone) ...@@ -583,7 +583,7 @@ static void reset_nodes(const zone_contents_t *zone)
* \brief Create new NSEC3 chain, add differences from current into a changeset. * \brief Create new NSEC3 chain, add differences from current into a changeset.
*/ */
int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl, int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset) changeset_t *changeset)
{ {
assert(zone); assert(zone);
assert(changeset); assert(changeset);
......
...@@ -40,6 +40,6 @@ ...@@ -40,6 +40,6 @@
* \return KNOT_E* * \return KNOT_E*
*/ */
int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl, int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset); changeset_t *changeset);
#endif // _KNOT_DNSSEC_NSEC3_CHAIN_FIX_H_ #endif // _KNOT_DNSSEC_NSEC3_CHAIN_FIX_H_
...@@ -64,7 +64,7 @@ static int init_dnssec_structs(const zone_contents_t *zone, ...@@ -64,7 +64,7 @@ static int init_dnssec_structs(const zone_contents_t *zone,
} }
static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
knot_changeset_t *out_ch, bool force, changeset_t *out_ch, bool force,
knot_update_serial_t soa_up, uint32_t *refresh_at) knot_update_serial_t soa_up, uint32_t *refresh_at)
{ {
assert(zone); assert(zone);
...@@ -79,7 +79,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -79,7 +79,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
uint32_t new_serial = zone_contents_next_serial(zone, zone_config->serial_policy); uint32_t new_serial = zone_contents_next_serial(zone, zone_config->serial_policy);
dbg_dnssec_verb("Changeset empty before generating NSEC chain: %d\n", dbg_dnssec_verb("Changeset empty before generating NSEC chain: %d\n",
knot_changeset_is_empty(out_ch)); changeset_is_empty(out_ch));
// Init needed structs // Init needed structs
knot_zone_keys_t zone_keys = { '\0' }; knot_zone_keys_t zone_keys = { '\0' };
...@@ -102,7 +102,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -102,7 +102,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
return result; return result;
} }
dbg_dnssec_verb("Changeset empty after generating NSEC chain: %d\n", dbg_dnssec_verb("Changeset empty after generating NSEC chain: %d\n",
knot_changeset_is_empty(out_ch)); changeset_is_empty(out_ch));
// add missing signatures // add missing signatures
result = knot_zone_sign(zone, &zone_keys, &policy, out_ch, result = knot_zone_sign(zone, &zone_keys, &policy, out_ch,
...@@ -115,16 +115,16 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -115,16 +115,16 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
return result; return result;
} }
dbg_dnssec_verb("Changeset emtpy after signing: %d\n", dbg_dnssec_verb("Changeset emtpy after signing: %d\n",
knot_changeset_is_empty(out_ch)); changeset_is_empty(out_ch));
// Check if only SOA changed // Check if only SOA changed
if (knot_changeset_is_empty(out_ch) && if (changeset_is_empty(out_ch) &&
!knot_zone_sign_soa_expired(zone, &zone_keys, &policy)) { !knot_zone_sign_soa_expired(zone, &zone_keys, &policy)) {
log_zone_info("%s No signing performed, zone is valid.\n", log_zone_info("%s No signing performed, zone is valid.\n",
msgpref); msgpref);
free(msgpref); free(msgpref);
knot_free_zone_keys(&zone_keys); knot_free_zone_keys(&zone_keys);
assert(knot_changeset_is_empty(out_ch)); assert(changeset_is_empty(out_ch));
return KNOT_EOK; return KNOT_EOK;
} }
...@@ -153,7 +153,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -153,7 +153,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
} }
int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
knot_changeset_t *out_ch, changeset_t *out_ch,
knot_update_serial_t soa_up, uint32_t *refresh_at) knot_update_serial_t soa_up, uint32_t *refresh_at)
{ {
if (zone == NULL || zone_config == NULL || out_ch == NULL) { if (zone == NULL || zone_config == NULL || out_ch == NULL) {
...@@ -164,7 +164,7 @@ int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -164,7 +164,7 @@ int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
} }
int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_config, int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_config,
knot_changeset_t *out_ch, uint32_t *refresh_at) changeset_t *out_ch, uint32_t *refresh_at)
{ {
if (zone == NULL || zone_config == NULL || out_ch == NULL) { if (zone == NULL || zone_config == NULL || out_ch == NULL) {
return KNOT_EINVAL; return KNOT_EINVAL;
...@@ -175,8 +175,8 @@ int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_c ...@@ -175,8 +175,8 @@ int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_c
int knot_dnssec_sign_changeset(const zone_contents_t *zone, int knot_dnssec_sign_changeset(const zone_contents_t *zone,
conf_zone_t *zone_config, conf_zone_t *zone_config,
const knot_changeset_t *in_ch, const changeset_t *in_ch,
knot_changeset_t *out_ch, changeset_t *out_ch,
uint32_t *refresh_at) uint32_t *refresh_at)
{ {
if (!refresh_at || zone == NULL || in_ch == NULL || out_ch == NULL) { if (!refresh_at || zone == NULL || in_ch == NULL || out_ch == NULL) {
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
knot_changeset_t *out_ch, changeset_t *out_ch,
knot_update_serial_t soa_up, uint32_t *refresh_at); knot_update_serial_t soa_up, uint32_t *refresh_at);
/*! /*!
...@@ -59,7 +59,7 @@ int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config, ...@@ -59,7 +59,7 @@ int knot_dnssec_zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_config, int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_config,
knot_changeset_t *out_ch, changeset_t *out_ch,
uint32_t *refresh_at); uint32_t *refresh_at);
/*! /*!
...@@ -76,8 +76,8 @@ int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_c ...@@ -76,8 +76,8 @@ int knot_dnssec_zone_sign_force(zone_contents_t *zone, const conf_zone_t *zone_c
*/ */
int knot_dnssec_sign_changeset(const zone_contents_t *zone, int knot_dnssec_sign_changeset(const zone_contents_t *zone,
conf_zone_t *zone_config, conf_zone_t *zone_config,
const knot_changeset_t *in_ch, const changeset_t *in_ch,
knot_changeset_t *out_ch, changeset_t *out_ch,
uint32_t *refresh_at); uint32_t *refresh_at);
#endif // _KNOT_DNSSEC_ZONE_EVENTS_H_ #endif // _KNOT_DNSSEC_ZONE_EVENTS_H_
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* \return KNOT_E* * \return KNOT_E*
*/ */
static int delete_nsec3_chain(const zone_contents_t *zone, static int delete_nsec3_chain(const zone_contents_t *zone,
knot_changeset_t *changeset) changeset_t *changeset)
{ {
assert(zone); assert(zone);
assert(changeset); assert(changeset);
...@@ -149,14 +149,14 @@ static int mark_nsec3(knot_rrset_t *rrset, void *data) ...@@ -149,14 +149,14 @@ static int mark_nsec3(knot_rrset_t *rrset, void *data)
* For each NSEC3 RRSet in the changeset finds its node and marks it with the * For each NSEC3 RRSet in the changeset finds its node and marks it with the
* 'removed' flag. * 'removed' flag.
*/ */
static int mark_removed_nsec3(knot_changeset_t *out_ch, static int mark_removed_nsec3(changeset_t *out_ch,
const zone_contents_t *zone) const zone_contents_t *zone)
{ {
if (knot_zone_tree_is_empty(zone->nsec3_nodes)) { if (knot_zone_tree_is_empty(zone->nsec3_nodes)) {
return KNOT_EOK; return KNOT_EOK;
} }
int ret = knot_changeset_apply(out_ch, KNOT_CHANGESET_REMOVE, int ret = changeset_apply(out_ch, CHANGESET_REMOVE,
mark_nsec3, (void *)zone->nsec3_nodes); mark_nsec3, (void *)zone->nsec3_nodes);
return ret; return ret;
} }
...@@ -246,7 +246,7 @@ knot_dname_t *knot_nsec3_hash_to_dname(const uint8_t *hash, size_t hash_size, ...@@ -246,7 +246,7 @@ knot_dname_t *knot_nsec3_hash_to_dname(const uint8_t *hash, size_t hash_size,
* \brief Create NSEC or NSEC3 chain in the zone. * \brief Create NSEC or NSEC3 chain in the zone.
*/ */
int knot_zone_create_nsec_chain(const zone_contents_t *zone, int knot_zone_create_nsec_chain(const zone_contents_t *zone,
knot_changeset_t *changeset, changeset_t *changeset,
const knot_zone_keys_t *zone_keys, const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy) const knot_dnssec_policy_t *policy)
{ {
......
...@@ -81,7 +81,7 @@ knot_dname_t *knot_create_nsec3_owner(const knot_dname_t *owner, ...@@ -81,7 +81,7 @@ knot_dname_t *knot_create_nsec3_owner(const knot_dname_t *owner,
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_zone_create_nsec_chain(const zone_contents_t *zone, int knot_zone_create_nsec_chain(const zone_contents_t *zone,
knot_changeset_t *changeset, changeset_t *changeset,
const knot_zone_keys_t *zone_keys, const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy); const knot_dnssec_policy_t *policy);
......
This diff is collapsed.
...@@ -62,7 +62,7 @@ typedef struct signed_info { ...@@ -62,7 +62,7 @@ typedef struct signed_info {
int knot_zone_sign(const zone_contents_t *zone, int knot_zone_sign(const zone_contents_t *zone,
const knot_zone_keys_t *zone_keys, const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy, const knot_dnssec_policy_t *policy,
knot_changeset_t *out_ch, uint32_t *refresh_at); changeset_t *out_ch, uint32_t *refresh_at);
/*! /*!
* \brief Update and sign SOA and store performed changes in changeset. * \brief Update and sign SOA and store performed changes in changeset.
...@@ -77,7 +77,7 @@ int knot_zone_sign(const zone_contents_t *zone, ...@@ -77,7 +77,7 @@ int knot_zone_sign(const zone_contents_t *zone,
int knot_zone_sign_update_soa(const knot_rrset_t *soa, const knot_rrset_t *rrsigs, int knot_zone_sign_update_soa(const knot_rrset_t *soa, const knot_rrset_t *rrsigs,
const knot_zone_keys_t *zone_keys, const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy, const knot_dnssec_policy_t *policy,
uint32_t new_serial, knot_changeset_t *changeset); uint32_t new_serial, changeset_t *changeset);
/*! /*!
* \brief Check if zone SOA signatures are expired. * \brief Check if zone SOA signatures are expired.
...@@ -105,8 +105,8 @@ bool knot_zone_sign_soa_expired(const zone_contents_t *zone, ...@@ -105,8 +105,8 @@ bool knot_zone_sign_soa_expired(const zone_contents_t *zone,
* \return Error code, KNOT_EOK if successful. * \return Error code, KNOT_EOK if successful.
*/ */
int knot_zone_sign_changeset(const zone_contents_t *zone, int knot_zone_sign_changeset(const zone_contents_t *zone,
const knot_changeset_t *in_ch, const changeset_t *in_ch,
knot_changeset_t *out_ch, changeset_t *out_ch,
const knot_zone_keys_t *zone_keys, const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy); const knot_dnssec_policy_t *policy);
...@@ -121,7 +121,7 @@ int knot_zone_sign_changeset(const zone_contents_t *zone, ...@@ -121,7 +121,7 @@ int knot_zone_sign_changeset(const zone_contents_t *zone,
*/ */
int knot_zone_sign_nsecs_in_changeset(const knot_zone_keys_t *zone_keys, int knot_zone_sign_nsecs_in_changeset(const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy, const knot_dnssec_policy_t *policy,
knot_changeset_t *changeset); changeset_t *changeset);
/*! /*!
* \brief Checks whether RRSet in a node has to be signed. Will not return * \brief Checks whether RRSet in a node has to be signed. Will not return
......
...@@ -235,7 +235,7 @@ static void axfr_answer_cleanup(struct answer_data *data) ...@@ -235,7 +235,7 @@ static void axfr_answer_cleanup(struct answer_data *data)
{ {
struct xfr_proc *proc = data->ext; struct xfr_proc *proc = data->ext;
if (proc) { if (proc) {
zone_contents_deep_free(&proc->zone); zone_contents_deep_free(&proc->contents);
mm_free(data->mm, proc); mm_free(data->mm, proc);
data->ext = NULL; data->ext = NULL;
} }
...@@ -260,7 +260,7 @@ static int axfr_answer_init(struct answer_data *data) ...@@ -260,7 +260,7 @@ static int axfr_answer_init(struct answer_data *data)
} }
memset(proc, 0, sizeof(struct xfr_proc)); memset(proc, 0, sizeof(struct xfr_proc));
proc->zone = new_contents; proc->contents = new_contents;
gettimeofday(&proc->tstamp, NULL); gettimeofday(&proc->tstamp, NULL);
/* Set up cleanup callback. */ /* Set up cleanup callback. */
...@@ -284,23 +284,23 @@ static int axfr_answer_finalize(struct answer_data *data) ...@@ -284,23 +284,23 @@ static int axfr_answer_finalize(struct answer_data *data)
* marked authoritative / delegation point. * marked authoritative / delegation point.
*/ */
struct xfr_proc *proc = data->ext; struct xfr_proc *proc = data->ext;
int rc = zone_contents_adjust_full(proc->zone, NULL, NULL); int rc = zone_contents_adjust_full(proc->contents, NULL, NULL);
if (rc != KNOT_EOK) { if (rc != KNOT_EOK) {
return rc; return rc;
} }
/* Write zone file. */ /* Write zone file. */
zone_t *zone = data->param->zone; zone_t *zone = data->param->zone;
rc = zonefile_write(zone->conf->file, proc->zone, data->param->remote); rc = zonefile_write(zone->conf->file, proc->contents, data->param->remote);
if (rc != KNOT_EOK) { if (rc != KNOT_EOK) {
return rc; return rc;
} }
/* Switch contents. */ /* Switch contents. */
zone_contents_t *old_contents = update_switch_contents(zone, proc->zone); zone_contents_t *old_contents = update_switch_contents(zone, proc->contents);
AXFRIN_LOG(LOG_INFO, "Serial %u -> %u", AXFRIN_LOG(LOG_INFO, "Serial %u -> %u",
zone_contents_serial(old_contents), zone_contents_serial(old_contents),
zone_contents_serial(proc->zone)); zone_contents_serial(proc->contents));
AXFRIN_LOG(LOG_INFO, "Finished in %.02fs (%u messages, ~%.01fkB).", AXFRIN_LOG(LOG_INFO, "Finished in %.02fs (%u messages, ~%.01fkB).",
time_diff(&proc->tstamp, &now) / 1000.0, time_diff(&proc->tstamp, &now) / 1000.0,
...@@ -308,7 +308,7 @@ static int axfr_answer_finalize(struct answer_data *data) ...@@ -308,7 +308,7 @@ static int axfr_answer_finalize(struct answer_data *data)
/* Do not free new contents with cleanup. */ /* Do not free new contents with cleanup. */
zone_contents_deep_free(&old_contents); zone_contents_deep_free(&old_contents);
proc->zone = NULL; proc->contents = NULL;
return KNOT_EOK; return KNOT_EOK;
} }
...@@ -322,7 +322,7 @@ static int process_axfr_packet(knot_pkt_t *pkt, struct xfr_proc *proc) ...@@ -322,7 +322,7 @@ static int process_axfr_packet(knot_pkt_t *pkt, struct xfr_proc *proc)
++proc->npkts; ++proc->npkts;
// Init zone creator // Init zone creator
zcreator_t zc = {.z = proc->zone, .master = false, .ret = KNOT_EOK }; zcreator_t zc = {.z = proc->contents, .master = false, .ret = KNOT_EOK };
const knot_pktsection_t *answer = knot_pkt_section(pkt, KNOT_ANSWER); const knot_pktsection_t *answer = knot_pkt_section(pkt, KNOT_ANSWER);
for (uint16_t i = 0; i < answer->count; ++i) { for (uint16_t i = 0; i < answer->count; ++i) {
......
...@@ -39,7 +39,7 @@ struct xfr_proc { ...@@ -39,7 +39,7 @@ struct xfr_proc {
unsigned npkts; /* Packets processed. */ unsigned npkts; /* Packets processed. */
unsigned nbytes; /* Bytes processed. */ unsigned nbytes; /* Bytes processed. */
struct timeval tstamp; /* Start time. */ struct timeval tstamp; /* Start time. */
zone_contents_t *zone; /* Processed zone. */ zone_contents_t *contents; /* Processed zone. */
}; };
/*! \brief Generic transfer processing (reused for IXFR). /*! \brief Generic transfer processing (reused for IXFR).
......
This diff is collapsed.
...@@ -51,7 +51,7 @@ int ixfr_query(knot_pkt_t *pkt, struct query_data *qdata); ...@@ -51,7 +51,7 @@ int ixfr_query(knot_pkt_t *pkt, struct query_data *qdata);
* \retval FAIL if it encountered an error, retry over AXFR will be done. * \retval FAIL if it encountered an error, retry over AXFR will be done.
* \retval DONE if finished. * \retval DONE if finished.
*/ */
int ixfrin_process_answer(knot_pkt_t *pkt, struct answer_data *adata); int ixfr_process_answer(knot_pkt_t *pkt, struct answer_data *adata);
#endif /* _KNOT_IXFR_H_ */ #endif /* _KNOT_IXFR_H_ */
......
...@@ -113,7 +113,7 @@ static int process_answer(knot_pkt_t *pkt, knot_process_t *ctx) ...@@ -113,7 +113,7 @@ static int process_answer(knot_pkt_t *pkt, knot_process_t *ctx)
next_state = axfr_process_answer(pkt, data); next_state = axfr_process_answer(pkt, data);
break; break;
case KNOT_RESPONSE_IXFR: case KNOT_RESPONSE_IXFR:
next_state = ixfrin_process_answer(pkt, data); next_state = ixfr_process_answer(pkt, data);
break; break;
case KNOT_RESPONSE_NOTIFY: case KNOT_RESPONSE_NOTIFY:
next_state = notify_process_answer(pkt, data); next_state = notify_process_answer(pkt, data);
...@@ -142,4 +142,4 @@ static const knot_process_module_t PROCESS_ANSWER_MODULE = { ...@@ -142,4 +142,4 @@ static const knot_process_module_t PROCESS_ANSWER_MODULE = {
const knot_process_module_t *process_answer_get_module(void) const knot_process_module_t *process_answer_get_module(void)
{ {
return &PROCESS_ANSWER_MODULE; return &PROCESS_ANSWER_MODULE;
} }
\ No newline at end of file
...@@ -135,13 +135,13 @@ static bool zones_nsec3param_changed(const zone_contents_t *old_contents, ...@@ -135,13 +135,13 @@ static bool zones_nsec3param_changed(const zone_contents_t *old_contents,
} }
static int sign_update(zone_t *zone, const zone_contents_t *old_contents, static int sign_update(zone_t *zone, const zone_contents_t *old_contents,
zone_contents_t *new_contents, knot_changeset_t *ddns_ch) zone_contents_t *new_contents, changeset_t *ddns_ch)
{ {
knot_changesets_t *sec_chs = knot_changesets_create(1); changesets_t *sec_chs = changesets_create(1);
if (sec_chs == NULL) { if (sec_chs == NULL) {
return KNOT_ENOMEM; return KNOT_ENOMEM;
} }
knot_changeset_t *sec_ch = knot_changesets_get_last(sec_chs); changeset_t *sec_ch = changesets_get_last(sec_chs);
/* /*
* Check if the UPDATE changed DNSKEYs or NSEC3PARAM. * Check if the UPDATE changed DNSKEYs or NSEC3PARAM.
...@@ -162,7 +162,7 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents, ...@@ -162,7 +162,7 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents,
&refresh_at); &refresh_at);
} }
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL); changesets_free(&sec_chs, NULL);
return ret; return ret;
} }
...@@ -170,14 +170,14 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents, ...@@ -170,14 +170,14 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents,
zone_contents_set_gen_old(new_contents); zone_contents_set_gen_old(new_contents);
ret = apply_changesets_directly(new_contents, sec_chs); ret = apply_changesets_directly(new_contents, sec_chs);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL); changesets_free(&sec_chs, NULL);
return ret; return ret;
} }
// Merge changesets // Merge changesets
ret = knot_changeset_merge(ddns_ch, sec_ch); ret = changeset_merge(ddns_ch, sec_ch);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL); changesets_free(&sec_chs, NULL);
return ret; return ret;
} }
...@@ -203,20 +203,20 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata) ...@@ -203,20 +203,20 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
} }
// Create DDNS changesets // Create DDNS changesets
knot_changesets_t *ddns_chs = knot_changesets_create(1); changesets_t *ddns_chs = changesets_create(1);
if (ddns_chs == NULL) { if (ddns_chs == NULL) {
*rcode = KNOT_RCODE_SERVFAIL; *rcode = KNOT_RCODE_SERVFAIL;
return KNOT_ENOMEM; return KNOT_ENOMEM;
} }
knot_changeset_t *ddns_ch = knot_changesets_get_last(ddns_chs); changeset_t *ddns_ch = changesets_get_last(ddns_chs);
ret = ddns_process_update(zone, query, ddns_ch, rcode); ret = ddns_process_update(zone, query, ddns_ch, rcode);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
knot_changesets_free(&ddns_chs, NULL); changesets_free(&ddns_chs, NULL);
return ret; return ret;
} }
zone_contents_t *new_contents = NULL; zone_contents_t *new_contents = NULL;
const bool change_made = !knot_changeset_is_empty(ddns_ch); const bool change_made = !changeset_is_empty(ddns_ch);
if (change_made) { if (change_made) {
ret = apply_changesets(zone, ddns_chs, &new_contents); ret = apply_changesets(zone, ddns_chs, &new_contents);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
...@@ -225,11 +225,11 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata) ...@@ -225,11 +225,11 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
} else { } else {
*rcode = KNOT_RCODE_SERVFAIL; *rcode = KNOT_RCODE_SERVFAIL;
} }
knot_changesets_free(&ddns_chs, NULL); changesets_free(&ddns_chs, NULL);
return ret; return ret;
} }
} else { } else {
knot_changesets_free(&ddns_chs, NULL); changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_NOERROR; *rcode = KNOT_RCODE_NOERROR;
return KNOT_EOK; return KNOT_EOK;
} }
...@@ -239,7 +239,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata) ...@@ -239,7 +239,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
ret = sign_update(zone, zone->contents, new_contents, ddns_ch); ret = sign_update(zone, zone->contents, new_contents, ddns_ch);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
update_rollback(ddns_chs, &new_contents); update_rollback(ddns_chs, &new_contents);
knot_changesets_free(&ddns_chs, NULL); changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_SERVFAIL; *rcode = KNOT_RCODE_SERVFAIL;
return ret; return ret;
} }
...@@ -249,7 +249,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata) ...@@ -249,7 +249,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
ret = zone_change_store(zone, ddns_chs); ret = zone_change_store(zone, ddns_chs);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
update_rollback(ddns_chs, &new_contents); update_rollback(ddns_chs, &new_contents);
knot_changesets_free(&ddns_chs, NULL); changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_SERVFAIL; *rcode = KNOT_RCODE_SERVFAIL;
return ret; return ret;
} }
...@@ -259,7 +259,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata) ...@@ -259,7 +259,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
update_free_old_zone(&old_contents); update_free_old_zone(&old_contents);