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,
dbg_dnssec_detail("Adding new NSEC to changeset.\n");
// Add new NSEC to the changeset (no matter if old was removed)
return knot_changeset_add_rrset(data->changeset, new_nsec,
KNOT_CHANGESET_ADD);
return changeset_add_rrset(data->changeset, new_nsec,
CHANGESET_ADD);
}
/* - API - iterations ------------------------------------------------------- */
......@@ -205,7 +205,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes,
* \brief Add entry for removed NSEC to the changeset.
*/
int knot_nsec_changeset_remove(const zone_node_t *n,
knot_changeset_t *changeset)
changeset_t *changeset)
{
if (changeset == NULL) {
return KNOT_EINVAL;
......@@ -219,8 +219,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n,
}
if (nsec) {
// update changeset
result = knot_changeset_add_rrset(changeset, nsec,
KNOT_CHANGESET_REMOVE);
result = changeset_add_rrset(changeset, nsec,
CHANGESET_REMOVE);
if (result != KNOT_EOK) {
knot_rrset_free(&nsec, NULL);
return result;
......@@ -253,8 +253,8 @@ int knot_nsec_changeset_remove(const zone_node_t *n,
}
// store RRSIG
result = knot_changeset_add_rrset(changeset, synth_rrsigs,
KNOT_CHANGESET_REMOVE);
result = changeset_add_rrset(changeset, synth_rrsigs,
CHANGESET_REMOVE);
if (result != KNOT_EOK) {
knot_rrset_free(&synth_rrsigs, NULL);
return result;
......@@ -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.
*/
int knot_nsec_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset)
changeset_t *changeset)
{
assert(zone);
assert(zone->nodes);
......
......@@ -39,7 +39,7 @@
*/
typedef struct {
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
} nsec_chain_iterate_data_t;
......@@ -96,7 +96,7 @@ int knot_nsec_chain_iterate_create(knot_zone_tree_t *nodes,
* \return Error code, KNOT_EOK if successful.
*/
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
......@@ -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.
*/
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_
......@@ -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,
knot_zone_tree_t *nsec3_nodes,
knot_changeset_t *chgset)
changeset_t *chgset)
{
assert(zone);
assert(nsec3_nodes);
......@@ -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.
*/
int knot_nsec3_create_chain(const zone_contents_t *zone, uint32_t ttl,
knot_changeset_t *changeset)
changeset_t *changeset)
{
assert(zone);
assert(changeset);
......
......@@ -40,6 +40,6 @@
* \return KNOT_E*
*/
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_
......@@ -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,
knot_changeset_t *out_ch, bool force,
changeset_t *out_ch, bool force,
knot_update_serial_t soa_up, uint32_t *refresh_at)
{
assert(zone);
......@@ -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);
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
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,
return result;
}
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
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,
return result;
}
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
if (knot_changeset_is_empty(out_ch) &&
if (changeset_is_empty(out_ch) &&
!knot_zone_sign_soa_expired(zone, &zone_keys, &policy)) {
log_zone_info("%s No signing performed, zone is valid.\n",
msgpref);
free(msgpref);
knot_free_zone_keys(&zone_keys);
assert(knot_changeset_is_empty(out_ch));
assert(changeset_is_empty(out_ch));
return KNOT_EOK;
}
......@@ -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,
knot_changeset_t *out_ch,
changeset_t *out_ch,
knot_update_serial_t soa_up, uint32_t *refresh_at)
{
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,
}
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) {
return KNOT_EINVAL;
......@@ -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,
conf_zone_t *zone_config,
const knot_changeset_t *in_ch,
knot_changeset_t *out_ch,
const changeset_t *in_ch,
changeset_t *out_ch,
uint32_t *refresh_at)
{
if (!refresh_at || zone == NULL || in_ch == NULL || out_ch == NULL) {
......
......@@ -44,7 +44,7 @@
* \return Error code, KNOT_EOK if successful.
*/
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);
/*!
......@@ -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.
*/
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);
/*!
......@@ -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,
conf_zone_t *zone_config,
const knot_changeset_t *in_ch,
knot_changeset_t *out_ch,
const changeset_t *in_ch,
changeset_t *out_ch,
uint32_t *refresh_at);
#endif // _KNOT_DNSSEC_ZONE_EVENTS_H_
......
......@@ -44,7 +44,7 @@
* \return KNOT_E*
*/
static int delete_nsec3_chain(const zone_contents_t *zone,
knot_changeset_t *changeset)
changeset_t *changeset)
{
assert(zone);
assert(changeset);
......@@ -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
* '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)
{
if (knot_zone_tree_is_empty(zone->nsec3_nodes)) {
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);
return ret;
}
......@@ -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.
*/
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_dnssec_policy_t *policy)
{
......
......@@ -81,7 +81,7 @@ knot_dname_t *knot_create_nsec3_owner(const knot_dname_t *owner,
* \return Error code, KNOT_EOK if successful.
*/
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_dnssec_policy_t *policy);
......
This diff is collapsed.
......@@ -62,7 +62,7 @@ typedef struct signed_info {
int knot_zone_sign(const zone_contents_t *zone,
const knot_zone_keys_t *zone_keys,
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.
......@@ -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,
const knot_zone_keys_t *zone_keys,
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.
......@@ -105,8 +105,8 @@ bool knot_zone_sign_soa_expired(const zone_contents_t *zone,
* \return Error code, KNOT_EOK if successful.
*/
int knot_zone_sign_changeset(const zone_contents_t *zone,
const knot_changeset_t *in_ch,
knot_changeset_t *out_ch,
const changeset_t *in_ch,
changeset_t *out_ch,
const knot_zone_keys_t *zone_keys,
const knot_dnssec_policy_t *policy);
......@@ -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,
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
......
......@@ -235,7 +235,7 @@ static void axfr_answer_cleanup(struct answer_data *data)
{
struct xfr_proc *proc = data->ext;
if (proc) {
zone_contents_deep_free(&proc->zone);
zone_contents_deep_free(&proc->contents);
mm_free(data->mm, proc);
data->ext = NULL;
}
......@@ -260,7 +260,7 @@ static int axfr_answer_init(struct answer_data *data)
}
memset(proc, 0, sizeof(struct xfr_proc));
proc->zone = new_contents;
proc->contents = new_contents;
gettimeofday(&proc->tstamp, NULL);
/* Set up cleanup callback. */
......@@ -284,23 +284,23 @@ static int axfr_answer_finalize(struct answer_data *data)
* marked authoritative / delegation point.
*/
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) {
return rc;
}
/* Write zone file. */
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) {
return rc;
}
/* 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",
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).",
time_diff(&proc->tstamp, &now) / 1000.0,
......@@ -308,7 +308,7 @@ static int axfr_answer_finalize(struct answer_data *data)
/* Do not free new contents with cleanup. */
zone_contents_deep_free(&old_contents);
proc->zone = NULL;
proc->contents = NULL;
return KNOT_EOK;
}
......@@ -322,7 +322,7 @@ static int process_axfr_packet(knot_pkt_t *pkt, struct xfr_proc *proc)
++proc->npkts;
// 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);
for (uint16_t i = 0; i < answer->count; ++i) {
......
......@@ -39,7 +39,7 @@ struct xfr_proc {
unsigned npkts; /* Packets processed. */
unsigned nbytes; /* Bytes processed. */
struct timeval tstamp; /* Start time. */
zone_contents_t *zone; /* Processed zone. */
zone_contents_t *contents; /* Processed zone. */
};
/*! \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);
* \retval FAIL if it encountered an error, retry over AXFR will be done.
* \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_ */
......
......@@ -113,7 +113,7 @@ static int process_answer(knot_pkt_t *pkt, knot_process_t *ctx)
next_state = axfr_process_answer(pkt, data);
break;
case KNOT_RESPONSE_IXFR:
next_state = ixfrin_process_answer(pkt, data);
next_state = ixfr_process_answer(pkt, data);
break;
case KNOT_RESPONSE_NOTIFY:
next_state = notify_process_answer(pkt, data);
......
......@@ -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,
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) {
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.
......@@ -162,7 +162,7 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents,
&refresh_at);
}
if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL);
changesets_free(&sec_chs, NULL);
return ret;
}
......@@ -170,14 +170,14 @@ static int sign_update(zone_t *zone, const zone_contents_t *old_contents,
zone_contents_set_gen_old(new_contents);
ret = apply_changesets_directly(new_contents, sec_chs);
if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL);
changesets_free(&sec_chs, NULL);
return ret;
}
// Merge changesets
ret = knot_changeset_merge(ddns_ch, sec_ch);
ret = changeset_merge(ddns_ch, sec_ch);
if (ret != KNOT_EOK) {
knot_changesets_free(&sec_chs, NULL);
changesets_free(&sec_chs, NULL);
return ret;
}
......@@ -203,20 +203,20 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
}
// Create DDNS changesets
knot_changesets_t *ddns_chs = knot_changesets_create(1);
changesets_t *ddns_chs = changesets_create(1);
if (ddns_chs == NULL) {
*rcode = KNOT_RCODE_SERVFAIL;
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);
if (ret != KNOT_EOK) {
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
return ret;
}
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) {
ret = apply_changesets(zone, ddns_chs, &new_contents);
if (ret != KNOT_EOK) {
......@@ -225,11 +225,11 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
} else {
*rcode = KNOT_RCODE_SERVFAIL;
}
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
return ret;
}
} else {
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_NOERROR;
return KNOT_EOK;
}
......@@ -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);
if (ret != KNOT_EOK) {
update_rollback(ddns_chs, &new_contents);
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_SERVFAIL;
return ret;
}
......@@ -249,7 +249,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
ret = zone_change_store(zone, ddns_chs);
if (ret != KNOT_EOK) {
update_rollback(ddns_chs, &new_contents);
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
*rcode = KNOT_RCODE_SERVFAIL;
return ret;
}
......@@ -259,7 +259,7 @@ static int process_authenticated(uint16_t *rcode, struct query_data *qdata)
update_free_old_zone(&old_contents);
update_cleanup(ddns_chs);
knot_changesets_free(&ddns_chs, NULL);
changesets_free(&ddns_chs, NULL);
/* Trim extra heap. */
mem_trim();
......
......@@ -953,7 +953,7 @@ bool journal_exists(const char *path)
}
/*! \brief No doc here. Moved from zones.h (@mvavrusa) */
static int changesets_unpack(knot_changeset_t *chs)
static int changesets_unpack(changeset_t *chs)
{
knot_rrset_t *rrset = NULL;
......@@ -963,8 +963,6 @@ static int changesets_unpack(knot_changeset_t *chs)
return KNOT_EMALF;
}
size_t remaining = chs->size;
memcpy(&chs->flags, chs->data, sizeof(uint32_t));
remaining -= sizeof(uint32_t);
/* Read initial changeset RRSet - SOA. */
uint8_t *stream = chs->data + (chs->size - remaining);
......@@ -979,7 +977,7 @@ static int changesets_unpack(knot_changeset_t *chs)
*/
assert(rrset->type == KNOT_RRTYPE_SOA);
assert(chs->serial_from == knot_soa_serial(&rrset->rrs));
knot_changeset_add_soa(chs, rrset, KNOT_CHANGESET_REMOVE);
changeset_add_soa(chs, rrset, CHANGESET_REMOVE);
/* Read remaining RRSets */
int in_remove_section = 1;
......@@ -998,8 +996,8 @@ static int changesets_unpack(knot_changeset_t *chs)
/* Move to ADD section if in REMOVE. */
if (in_remove_section) {
knot_changeset_add_soa(chs, rrset,
KNOT_CHANGESET_ADD);
changeset_add_soa(chs, rrset,
CHANGESET_ADD);
in_remove_section = 0;
} else {
/* Final SOA. */
......@@ -1009,14 +1007,14 @@ static int changesets_unpack(knot_changeset_t *chs)
} else {
/* Remove RRSets. */
if (in_remove_section) {
ret = knot_changeset_add_rrset(
ret = changeset_add_rrset(
chs, rrset,
KNOT_CHANGESET_REMOVE);
CHANGESET_REMOVE);
} else {
/* Add RRSets. */
ret = knot_changeset_add_rrset(
ret = changeset_add_rrset(
chs, rrset,
KNOT_CHANGESET_ADD);
CHANGESET_ADD);
}
}
}
......@@ -1038,14 +1036,9 @@ static int zones_rrset_write_to_mem(const knot_rrset_t *rr, char **entry,
return ret;
}
static int zones_serialize_and_store_chgset(const knot_changeset_t *chs,
static int zones_serialize_and_store_chgset(const changeset_t *chs,
char *entry, size_t max_size)
{
/* Write changeset flags. */
memcpy(entry, (char*)&chs->flags, sizeof(uint32_t));
entry += sizeof(uint32_t);
max_size -= sizeof(uint32_t);
/* Serialize SOA 'from'. */
int ret = zones_rrset_write_to_mem(chs->soa_from, &entry, &max_size);
if (ret != KNOT_EOK) {
......@@ -1085,7 +1078,7 @@ static int zones_serialize_and_store_chgset(const knot_changeset_t *chs,
return KNOT_EOK;
}
static int changeset_pack(const knot_changeset_t *chs, journal_t *j)
static int changeset_pack(const changeset_t *chs, journal_t *j)
{
assert(chs != NULL);
assert(j != NULL);
......@@ -1174,8 +1167,8 @@ finish:
static int load_changeset(journal_t *journal, journal_node_t *n, void *data)
{
knot_changesets_t *chsets = (knot_changesets_t *)data;
knot_changeset_t *chs = knot_changesets_create_changeset(chsets);
changesets_t *chsets = (changesets_t *)data;
changeset_t *chs = changesets_create_changeset(chsets);
if (chs == NULL) {
return KNOT_ERROR;
}
......@@ -1199,7 +1192,7 @@ static int load_changeset(journal_t *journal, journal_node_t *n, void *data)
return KNOT_EOK;
}
int journal_load_changesets(const char *path, knot_changesets_t *dst,
int journal_load_changesets(const char *path, changesets_t *dst,
uint32_t from, uint32_t to)
{
int ret = journal_walk(path, from, to, &load_changeset, dst);
......@@ -1213,7 +1206,7 @@ int journal_load_changesets(const char *path, knot_changesets_t *dst,
* Parses changesets from the binary format stored in chgsets->data
* into the changeset_t structures.
*/
knot_changeset_t* chs = NULL;
changeset_t* chs = NULL;
WALK_LIST(chs, dst->sets) {
ret = changesets_unpack(chs);
if (ret != KNOT_EOK) {
......@@ -1222,7 +1215,7 @@ int journal_load_changesets(const char *path, knot_changesets_t *dst,
}
/* Check for complete history. */
knot_changeset_t *last = knot_changesets_get_last(dst);
changeset_t *last = changesets_get_last(dst);
if (to != last->serial_to) {
return KNOT_ERANGE;
}
......@@ -1230,7 +1223,7 @@ int journal_load_changesets(const char *path, knot_changesets_t *dst,
return KNOT_EOK;
}
int journal_store_changesets(knot_changesets_t *src, const char *path, size_t size_limit)
int journal_store_changesets(changesets_t *src, const char *path, size_t size_limit)
{
if (src == NULL || path == NULL) {
return KNOT_EINVAL;
......@@ -1244,7 +1237,7 @@ int journal_store_changesets(knot_changesets_t *src, const char *path, size_t si
}
/* Begin writing to journal. */
knot_changeset_t *chs = NULL;
changeset_t *chs = NULL;
WALK_LIST(chs, src->sets) {
/* Make key from serials. */
ret = changeset_pack(chs, journal);
......
......@@ -102,7 +102,7 @@ typedef struct journal_t
* Journal defaults and constants.
*/
#define JOURNAL_NCOUNT 1024 /*!< Default node count. */
#define JOURNAL_MAGIC {'k', 'n', 'o', 't', '1', '5', '1'}
#define JOURNAL_MAGIC {'k', 'n', 'o', 't', '1', '5', '2'}
#define MAGIC_LENGTH 7
/* HEADER = magic, crc, max_entries, qhead, qtail */
#define JOURNAL_HSIZE (MAGIC_LENGTH + sizeof(crc_t) + sizeof(uint16_t) * 3)
......@@ -173,7 +173,7 @@ bool journal_exists(const char *path);
*
* \param changesets Double pointer to changesets structure to be freed.
*/
int journal_load_changesets(const char *path, knot_changesets_t *dst,
int journal_load_changesets(const char *path, changesets_t *dst,
uint32_t from, uint32_t to);
/*!
......@@ -192,7 +192,7 @@ int journal_load_changesets(const char *path, knot_changesets_t *dst,
* \todo Expects the xfr structure to be initialized in some way.
* \todo Update documentation!!!
*/
int journal_store_changesets(knot_changesets_t *src, const char *path, size_t size_limit);
int journal_store_changesets(changesets_t *src, const char *path, size_t size_limit);
/*! \brief Function for unmarking dirty nodes. */
int journal_mark_synced(const char *path);
......
......@@ -69,7 +69,7 @@ static int deserialize_rr(knot_rrset_t *rrset, const uint8_t *stream, uint32_t r
rdata_size - sizeof(uint32_t), ttl, NULL);
}
int changeset_binary_size(const knot_changeset_t *chgset, size_t *size)
int changeset_binary_size(const changeset_t *chgset, size_t *size)
{
if (chgset == NULL || size == NULL) {
return KNOT_EINVAL;
......
......@@ -38,7 +38,7 @@
*
* \return KNOT_E*
*/
int changeset_binary_size(const knot_changeset_t *chgset, size_t *size);
int changeset_binary_size(const changeset_t *chgset, size_t *size);
/*!
* \brief Serializes one RRSet into given stream.
......
......@@ -255,8 +255,8 @@ static void xfr_task_cleanup(knot_ns_xfr_t *rq)
rq->data = NULL;
}
} else if (rq->type == XFR_TYPE_IIN) {
knot_changesets_t *chs = (knot_changesets_t *)rq->data;
knot_changesets_free(&chs);
changesets_t *chs = (changesets_t *)rq->data;
changesets_free(&chs);
rq->data = NULL;
assert(rq->new_contents == NULL);
} else if (rq->type == XFR_TYPE_FORWARD) {
......@@ -599,7 +599,7 @@ static int xfr_task_finalize(knot_ns_xfr_t *rq)
rq->msg);
}
} else if (rq->type == XFR_TYPE_IIN) {
knot_changesets_t *chs = (knot_changesets_t *)rq->data;
changesets_t *chs = (changesets_t *)rq->data;
ret = zone_change_apply_and_store(chs, rq->zone,
&rq->new_contents,
rq->msg);
......
......@@ -242,7 +242,7 @@ static void clear_new_rrs(zone_node_t *node, uint16_t type)
}
/*! \brief Stores RR data for update cleanup. */
static int add_old_data(knot_changeset_t *chset, knot_rdata_t *old_data)
static int add_old_data(changeset_t *chset, knot_rdata_t *old_data)
{
if (ptrlist_add(&chset->old_data, old_data, NULL) == NULL) {
return KNOT_ENOMEM;
......@@ -252,7 +252,7 @@ static int add_old_data(knot_changeset_t *chset, knot_rdata_t *old_data)
}
/*! \brief Stores RR data for update rollback. */
static int add_new_data(knot_changeset_t *chset, knot_rdata_t *new_data)
static int add_new_data(changeset_t *chset, knot_rdata_t *new_data)
{
if (ptrlist_add(&chset->new_data, new_data, NULL) == NULL) {
return KNOT_ENOMEM;
......@@ -289,7 +289,7 @@ static bool can_remove(const zone_node_t *node, const knot_rrset_t *rr)
/*! \brief Removes single RR from zone contents. */
static int remove_rr(zone_node_t *node, const knot_rrset_t *rr,
knot_changeset_t *chset)
changeset_t *chset)
{
knot_rrset_t removed_rrset = node_rrset(node, rr->type);
knot_rdata_t *old_data = removed_rrset.rrs.data;
......@@ -329,7 +329,7 @@ static int remove_rr(zone_node_t *node, const knot_rrset_t *rr,
}
/*! \brief Removes all RRs from changeset from zone contents. */
static int apply_remove(zone_contents_t *contents, knot_changeset_t *chset)
static int apply_remove(zone_contents_t *contents, changeset_t *chset)
{
knot_rr_ln_t *rr_node = NULL;
WALK_LIST(rr_node, chset->remove) {
......@@ -354,7 +354,7 @@ static int apply_remove(zone_contents_t *contents, knot_changeset_t *chset)
/*! \brief Adds a single RR into zone contents. */
static int add_rr(zone_node_t *node, const knot_rrset_t *rr,
knot_changeset_t *chset, bool master)
changeset_t *chset, bool master)