Commit ca6b2810 authored by Jan Kadlec's avatar Jan Kadlec

new_node: Remove unnecessary rrset allocations, removed changes from

updates.

- DDNS and changeset application will not work now, but it wouldn't work
  before either
parent 633befbb
......@@ -100,14 +100,13 @@ static int connect_nsec_nodes(knot_node_t *a, knot_node_t *b,
return NSEC_NODE_SKIP;
}
knot_rrset_t *old_next_nsec = knot_node_create_rrset(b, KNOT_RRTYPE_NSEC);
int ret = 0;
/*!
* If the node has no other RRSets than NSEC (and possibly RRSIGs),
* just remove the NSEC and its RRSIG, they are redundant
*/
if (old_next_nsec != NULL
if (knot_node_rrtype_exists(b, KNOT_RRTYPE_NSEC)
&& knot_nsec_empty_nsec_and_rrsigs_in_node(b)) {
ret = knot_nsec_changeset_remove(b, data->changeset);
if (ret != KNOT_EOK) {
......@@ -124,9 +123,9 @@ static int connect_nsec_nodes(knot_node_t *a, knot_node_t *b,
return KNOT_ENOMEM;
}
knot_rrset_t *old_nsec = knot_node_create_rrset(a, KNOT_RRTYPE_NSEC);
if (old_nsec != NULL) {
if (knot_rrset_equal(new_nsec, old_nsec,
knot_rrset_t old_nsec = RRSET_INIT(a, KNOT_RRTYPE_NSEC);
if (!knot_rrset_empty(&old_nsec)) {
if (knot_rrset_equal(new_nsec, &old_nsec,
KNOT_RRSET_COMPARE_WHOLE)) {
// current NSEC is valid, do nothing
dbg_dnssec_detail("NSECs equal.\n");
......@@ -221,9 +220,6 @@ int knot_nsec_changeset_remove(const knot_node_t *n,
if (nsec == NULL) {
nsec = knot_node_create_rrset(n, KNOT_RRTYPE_NSEC3);
}
if (nsec == NULL) {
return KNOT_ENOMEM;
}
knot_rrset_t *rrsigs = knot_node_create_rrset(n, KNOT_RRTYPE_RRSIG);
if (nsec) {
// update changeset
......@@ -279,16 +275,14 @@ int knot_nsec_changeset_remove(const knot_node_t *n,
bool knot_nsec_empty_nsec_and_rrsigs_in_node(const knot_node_t *n)
{
assert(n);
knot_rrset_t **rrsets = knot_node_create_rrsets(n);
for (int i = 0; i < n->rrset_count; ++i) {
if (rrsets[i]->type != KNOT_RRTYPE_NSEC &&
rrsets[i]->type != KNOT_RRTYPE_RRSIG) {
knot_node_free_created_rrsets(n, rrsets);
knot_rrset_t rrset = RRSET_INIT_N(n, i);
if (rrset.type != KNOT_RRTYPE_NSEC &&
rrset.type != KNOT_RRTYPE_RRSIG) {
return false;
}
}
knot_node_free_created_rrsets(n, rrsets);
return true;
}
......
......@@ -89,14 +89,14 @@ static bool are_nsec3_nodes_equal(const knot_node_t *a, const knot_node_t *b)
*/
static bool node_should_be_signed_nsec3(const knot_node_t *n)
{
knot_rrset_t **node_rrsets = knot_node_create_rrsets(n);
for (int i = 0; i < n->rrset_count; i++) {
if (node_rrsets[i]->type == KNOT_RRTYPE_NSEC ||
node_rrsets[i]->type == KNOT_RRTYPE_RRSIG) {
knot_rrset_t rrset = RRSET_INIT_N(n, i);
if (rrset.type == KNOT_RRTYPE_NSEC ||
rrset.type == KNOT_RRTYPE_RRSIG) {
continue;
}
bool should_sign = false;
int ret = knot_zone_sign_rr_should_be_signed(n, node_rrsets[i],
int ret = knot_zone_sign_rr_should_be_signed(n, &rrset,
&should_sign);
assert(ret == KNOT_EOK); // No tree inside the function, no fail
if (should_sign) {
......@@ -122,7 +122,9 @@ static int shallow_copy_signature(const knot_node_t *from, knot_node_t *to)
if (from_sig == NULL) {
return KNOT_EOK;
}
return knot_node_add_rrset(to, from_sig, NULL);
int ret = knot_node_add_rrset(to, from_sig);
knot_rrset_free(&from_sig, NULL);
return ret;
}
/*!
......@@ -176,9 +178,8 @@ static void free_nsec3_tree(knot_zone_tree_t *nodes)
for (/* NOP */; !hattrie_iter_finished(it); hattrie_iter_next(it)) {
knot_node_t *node = (knot_node_t *)*hattrie_iter_val(it);
// newly allocated NSEC3 nodes
knot_rrset_t *nsec3 = knot_node_create_rrset(node,
KNOT_RRTYPE_NSEC3);
knot_rrset_free(&nsec3, NULL);
knot_rrs_t *nsec3 = knot_node_get_rrs(node, KNOT_RRTYPE_NSEC3);
knot_rrs_clear(nsec3, NULL);
knot_node_free(&node);
}
......
......@@ -495,14 +495,13 @@ static int sign_node_rrsets(const knot_node_t *node,
knot_rrset_t rrsigs;
knot_node_fill_rrset(node, KNOT_RRTYPE_RRSIG, &rrsigs);
knot_rrset_t **node_rrsets = knot_node_create_rrsets(node);
for (int i = 0; i < node->rrset_count; i++) {
const knot_rrset_t *rrset = node_rrsets[i];
if (rrset->type == KNOT_RRTYPE_RRSIG) {
knot_rrset_t rrset = RRSET_INIT_N(node, i);
if (rrset.type == KNOT_RRTYPE_RRSIG) {
continue;
}
bool should_sign = false;
result = knot_zone_sign_rr_should_be_signed(node, rrset,
result = knot_zone_sign_rr_should_be_signed(node, &rrset,
&should_sign);
if (result != KNOT_EOK) {
return result;
......@@ -512,10 +511,10 @@ static int sign_node_rrsets(const knot_node_t *node,
}
if (policy->forced_sign) {
result = force_resign_rrset(rrset, &rrsigs, zone_keys, policy,
result = force_resign_rrset(&rrset, &rrsigs, zone_keys, policy,
changeset);
} else {
result = resign_rrset(rrset, &rrsigs, zone_keys, policy,
result = resign_rrset(&rrset, &rrsigs, zone_keys, policy,
changeset, expires_at);
}
......@@ -524,8 +523,6 @@ static int sign_node_rrsets(const knot_node_t *node,
}
}
knot_node_free_created_rrsets(node, node_rrsets);
return remove_standalone_rrsigs(node, &rrsigs, changeset);
}
......@@ -1467,7 +1464,7 @@ int knot_zone_sign_rr_should_be_signed(const knot_node_t *node,
}
*should_sign = false; // Only one case at the end is set to true
if (node == NULL || rrset == NULL) {
if (node == NULL || knot_rrset_empty(rrset)) {
return KNOT_EOK;
}
......
......@@ -207,13 +207,12 @@ static int knot_ns_process_update(const knot_pkt_t *query,
dbg_ns_verb("Applying the UPDATE and creating changeset...\n");
ret = knot_ddns_process_update(contents_copy, query,
knot_changesets_get_last(chgs),
chgs->changes, rcode, new_serial);
rcode, new_serial);
if (ret != KNOT_EOK) {
dbg_ns("Failed to apply UPDATE to the zone copy or no update"
" made: %s\n", (ret < 0) ? knot_strerror(ret)
: "No change made.");
xfrin_rollback_update(old_contents, &contents_copy,
chgs->changes);
xfrin_rollback_update(old_contents, &contents_copy);
return ret;
}
......@@ -223,8 +222,7 @@ static int knot_ns_process_update(const knot_pkt_t *query,
if (ret != KNOT_EOK) {
dbg_ns("Failed to finalize updated zone: %s\n",
knot_strerror(ret));
xfrin_rollback_update(old_contents, &contents_copy,
chgs->changes);
xfrin_rollback_update(old_contents, &contents_copy);
*rcode = (ret == KNOT_EMALF) ? KNOT_RCODE_FORMERR
: KNOT_RCODE_SERVFAIL;
return ret;
......@@ -326,8 +324,7 @@ static int zones_process_update_auth(struct query_data *qdata)
sec_chs = knot_changesets_create();
sec_ch = knot_changesets_create_changeset(sec_chs);
if (sec_chs == NULL || sec_ch == NULL) {
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
knot_changesets_free(&chgsets);
free(msg);
return KNOT_ENOMEM;
......@@ -360,8 +357,7 @@ static int zones_process_update_auth(struct query_data *qdata)
if (ret != KNOT_EOK) {
log_zone_error("%s: Failed to sign incoming update (%s)"
"\n", msg, knot_strerror(ret));
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
knot_changesets_free(&chgsets);
knot_changesets_free(&sec_chs);
free(msg);
......@@ -376,8 +372,7 @@ static int zones_process_update_auth(struct query_data *qdata)
if (ret != KNOT_EOK) {
log_zone_error("%s: Failed to save new entry to journal (%s)\n",
msg, knot_strerror(ret));
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
zones_free_merged_changesets(chgsets, sec_chs);
free(msg);
return ret;
......@@ -414,8 +409,7 @@ static int zones_process_update_auth(struct query_data *qdata)
if (ret != KNOT_EOK) {
zones_store_changesets_rollback(transaction);
zones_free_merged_changesets(chgsets, sec_chs);
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
free(msg);
return ret;
}
......@@ -427,8 +421,7 @@ static int zones_process_update_auth(struct query_data *qdata)
if (ret != KNOT_EOK) {
log_zone_error("%s: Failed to commit new journal entry "
"(%s).\n", msg, knot_strerror(ret));
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
zones_free_merged_changesets(chgsets, sec_chs);
free(msg);
return ret;
......@@ -444,8 +437,7 @@ static int zones_process_update_auth(struct query_data *qdata)
log_zone_error("%s: Failed to replace current zone (%s)\n",
msg, knot_strerror(ret));
// Cleanup old and new contents
xfrin_rollback_update(old_contents, &new_contents,
chgsets->changes);
xfrin_rollback_update(old_contents, &new_contents);
/* Free changesets, but not the data. */
zones_free_merged_changesets(chgsets, sec_chs);
......@@ -455,9 +447,9 @@ static int zones_process_update_auth(struct query_data *qdata)
}
// Cleanup.
xfrin_cleanup_successful_update(chgsets->changes);
xfrin_cleanup_successful_update(NULL);
if (sec_chs) {
xfrin_cleanup_successful_update(sec_chs->changes);
xfrin_cleanup_successful_update(NULL);
}
// Free changesets, but not the data.
......
......@@ -1478,8 +1478,7 @@ int zones_store_and_apply_chgsets(knot_changesets_t *chs,
/* Commit transaction. */
ret = zones_store_changesets_commit(transaction);
if (ret != KNOT_EOK) {
xfrin_rollback_update(zone->contents, new_contents,
chs->changes);
xfrin_rollback_update(zone->contents, new_contents);
log_zone_error("%s Failed to commit stored changesets.\n", msgpref);
knot_changesets_free(&chs);
return ret;
......@@ -1495,15 +1494,14 @@ int zones_store_and_apply_chgsets(knot_changesets_t *chs,
if (switch_ret != KNOT_EOK) {
log_zone_error("%s Failed to replace current zone.\n", msgpref);
// Cleanup old and new contents
xfrin_rollback_update(zone->contents, new_contents,
chs->changes);
xfrin_rollback_update(zone->contents, new_contents);
/* Free changesets, but not the data. */
knot_changesets_free(&chs);
return KNOT_ERROR;
}
xfrin_cleanup_successful_update(chs->changes);
xfrin_cleanup_successful_update(NULL);
/* Free changesets, but not the data. */
knot_changesets_free(&chs);
......@@ -1926,8 +1924,7 @@ int zones_journal_apply(zone_t *zone)
XFR_TYPE_IIN);
rcu_read_lock();
if (apply_ret == KNOT_EOK) {
xfrin_cleanup_successful_update(
chsets->changes);
xfrin_cleanup_successful_update(NULL);
} else {
log_zone_error("Failed to apply "
"changesets to '%s' - Switch failed: "
......@@ -1937,8 +1934,7 @@ int zones_journal_apply(zone_t *zone)
// Cleanup old and new contents
xfrin_rollback_update(zone->contents,
&contents,
chsets->changes);
&contents);
}
}
}
......@@ -2020,7 +2016,6 @@ static int diff_after_load(zone_t *zone, zone_t *old_zone,
assert(!zones_changesets_empty(*diff_chs));
/* Apply DNSSEC changeset to the new zone. */
ret = xfrin_apply_changesets_directly(zone->contents,
(*diff_chs)->changes,
*diff_chs);
if (ret == KNOT_EOK) {
......@@ -2038,7 +2033,7 @@ static int diff_after_load(zone_t *zone, zone_t *old_zone,
return ret;
}
xfrin_cleanup_successful_update((*diff_chs)->changes);
xfrin_cleanup_successful_update(NULL);
knot_changesets_free(diff_chs);
assert(zone->conf->build_diffs);
}
......@@ -2109,7 +2104,6 @@ static int store_chgsets_after_load(zone_t *old_zone, zone_t *zone,
assert(!old_zone ||
old_zone->contents != zone->contents);
ret = xfrin_apply_changesets_directly(zone->contents,
diff_chs->changes,
diff_chs);
if (ret == KNOT_EOK) {
ret = xfrin_finalize_updated_zone(
......@@ -2133,7 +2127,7 @@ static int store_chgsets_after_load(zone_t *old_zone, zone_t *zone,
return ret;
}
xfrin_cleanup_successful_update(diff_chs->changes);
xfrin_cleanup_successful_update(NULL);
}
/* Commit transaction. */
......@@ -2162,8 +2156,7 @@ static int store_chgsets_after_load(zone_t *old_zone, zone_t *zone,
"switching zone (%s).\n",
zone->conf->name, knot_strerror(ret));
// Cleanup old and new contents
xfrin_rollback_update(zone->contents, &new_contents,
diff_chs->changes);
xfrin_rollback_update(zone->contents, &new_contents);
return ret;
}
......
......@@ -54,14 +54,6 @@ int knot_changesets_init(knot_changesets_t **changesets)
// Init list with changesets
init_list(&(*changesets)->sets);
// Init changes structure
(*changesets)->changes = xmalloc(sizeof(knot_changes_t));
// Init changes' allocator (storing RRs)
(*changesets)->changes->mem_ctx = (*changesets)->mmc_rr;
// Init changes' lists
init_list(&(*changesets)->changes->new_rrsets);
init_list(&(*changesets)->changes->old_rrsets);
return KNOT_EOK;
}
......@@ -178,32 +170,6 @@ int knot_changeset_add_rr(knot_changeset_t *chgs, knot_rrset_t *rr,
}
}
int knot_changes_add_rrset(knot_changes_t *ch, knot_rrset_t *rrset,
knot_changes_part_t part)
{
if (ch == NULL || rrset == NULL) {
return KNOT_EINVAL;
}
knot_rr_ln_t *rr_node =
ch->mem_ctx.alloc(ch->mem_ctx.ctx, sizeof(knot_rr_ln_t));
if (rr_node == NULL) {
// This will not happen with mp_alloc, but allocator can change
ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
rr_node->rr = rrset;
if (part == KNOT_CHANGES_NEW) {
add_tail(&ch->new_rrsets, (node_t *)rr_node);
} else {
assert(part == KNOT_CHANGES_OLD);
add_tail(&ch->old_rrsets, (node_t *)rr_node);
}
return KNOT_EOK;
}
static void knot_changeset_store_soa(knot_rrset_t **chg_soa,
uint32_t *chg_serial, knot_rrset_t *soa)
{
......@@ -337,7 +303,6 @@ void knot_changesets_free(knot_changesets_t **changesets)
knot_rrset_free(&(*changesets)->first_soa, NULL);
free((*changesets)->changes);
free(*changesets);
*changesets = NULL;
}
......@@ -65,23 +65,6 @@ typedef struct knot_rr_ln {
knot_rrset_t *rr; /*!< Actual usable data. */
} knot_rr_ln_t;
/*! \brief Partial changes done to zones - used for update/transfer rollback. */
typedef struct {
/*!
* Memory context. Ideally a pool allocator since there is a possibility
* of many changes in one transfer/update.
*/
mm_ctx_t mem_ctx;
/*!
* Deleted after successful update.
*/
list_t old_rrsets;
/*!
* Deleted after failed update.
*/
list_t new_rrsets;
} knot_changes_t;
/*----------------------------------------------------------------------------*/
/*!
......@@ -95,7 +78,6 @@ typedef struct {
size_t count; /*!< Changeset count. */
knot_rrset_t *first_soa; /*!< First received SOA. */
uint32_t flags; /*!< DDNS / IXFR flags. */
knot_changes_t *changes; /*!< Partial changes. */
} knot_changesets_t;
/*----------------------------------------------------------------------------*/
......@@ -105,11 +87,6 @@ typedef enum {
KNOT_CHANGESET_REMOVE
} knot_changeset_part_t;
typedef enum {
KNOT_CHANGES_OLD,
KNOT_CHANGES_NEW,
} knot_changes_part_t;
/*----------------------------------------------------------------------------*/
/*!
......@@ -246,20 +223,6 @@ int knot_changeset_apply(knot_changeset_t *changeset,
*/
void knot_changesets_free(knot_changesets_t **changesets);
/*!
* \brief Add RRSet to changes structure.
* RRSet is either inserted to 'old' or to 'new' list.
*
* \param chgs Change to add RRSet into.
* \param rrset RRSet to be added.
* \param part Add to 'old' or 'new'?
*
* \retval KNOT_EOK on success.
* \retval Error code on failure.
*/
int knot_changes_add_rrset(knot_changes_t *ch, knot_rrset_t *rrset,
knot_changes_part_t part);
/*!
* \brief Merges two changesets together, second changeset's lists are kept.
*
......@@ -275,11 +238,6 @@ int knot_changes_add_rrset(knot_changes_t *ch, knot_rrset_t *rrset,
*/
int knot_changeset_merge(knot_changeset_t *ch1, knot_changeset_t *ch2);
/*!
* \param changes Double pointer of changes structure to be freed.
*/
void knot_changes_free(knot_changes_t **changes);
#endif /* _KNOT_CHANGESETS_H_ */
/*! @} */
......@@ -674,13 +674,11 @@ static void knot_ddns_check_add_rr(knot_changeset_t *changeset,
static int knot_ddns_process_add_cname(knot_node_t *node,
const knot_rrset_t *rr,
knot_changeset_t *changeset,
knot_changes_t *changes)
knot_changeset_t *changeset)
{
assert(node != NULL);
assert(rr != NULL);
assert(changeset != NULL);
assert(changes != NULL);
dbg_ddns_detail("Adding CNAME RR.\n");
......@@ -697,20 +695,12 @@ static int knot_ddns_process_add_cname(knot_node_t *node,
return 1;
}
/* b) Store it to 'changes' */
ret = knot_changes_add_rrset(changes, removed, KNOT_CHANGES_OLD);
if (ret != KNOT_EOK) {
dbg_ddns("Failed to add removed RRSet to "
"'changes': %s\n", knot_strerror(ret));
return ret;
}
/* c) And remove it from the node. */
/* Remove it from the node. */
UNUSED(knot_node_remove_rrset(node, KNOT_RRTYPE_CNAME));
/* d) Check if this CNAME was not previously added by
* the UPDATE. If yes, remove it from the ADD
* section and do not add it to the REMOVE section.
/* Check if this CNAME was not previously added by
* the UPDATE. If yes, remove it from the ADD
* section and do not add it to the REMOVE section.
*/
knot_rrset_t **from_chgset = NULL;
size_t from_chgset_count = 0;
......@@ -766,17 +756,13 @@ static int knot_ddns_process_add_cname(knot_node_t *node,
/*----------------------------------------------------------------------------*/
static int knot_ddns_process_add_soa(knot_node_t *node,
const knot_rrset_t *rr,
knot_changes_t *changes)
const knot_rrset_t *rr)
{
assert(node != NULL);
assert(rr != NULL);
assert(changes != NULL);
dbg_ddns_detail("Adding SOA RR.\n");
int ret = 0;
/*
* Just remove the SOA from the node, together with its RRSIGs.
* Adding the RR is done in the caller function. Note that only SOA
......@@ -786,33 +772,21 @@ static int knot_ddns_process_add_soa(knot_node_t *node,
*/
/* Get the current SOA RR from the node. */
knot_rrset_t *removed = knot_node_create_rrset(node, KNOT_RRTYPE_SOA);
if (removed != NULL) {
knot_rrset_t removed = RRSET_INIT(node, KNOT_RRTYPE_SOA);
if (!knot_rrset_empty(&removed)) {
dbg_ddns_detail("Found SOA in the node.\n");
/* If they are identical, ignore. */
if (knot_rrset_equal(removed, rr, KNOT_RRSET_COMPARE_WHOLE)
== 1) {
if (knot_rrset_equal(&removed, rr, KNOT_RRSET_COMPARE_WHOLE)) {
dbg_ddns_detail("Old and new SOA identical.\n");
return 1;
}
/* Check that the serial is indeed larger than the current one*/
assert(knot_serial_compare(knot_rrs_soa_serial(&removed->rrs),
assert(knot_serial_compare(knot_rrs_soa_serial(&removed.rrs),
knot_rrs_soa_serial(&rr->rrs)) < 0);
/* 1) Store it to 'changes', together with its RRSIGs. */
ret = knot_changes_add_rrset(changes, removed, KNOT_CHANGES_OLD);
if (ret != KNOT_EOK) {
dbg_ddns("Failed to add removed RRSet to "
"'changes': %s\n", knot_strerror(ret));
return ret;
}
/* 2) And remove it from the node. */
UNUSED(knot_node_remove_rrset(node, KNOT_RRTYPE_SOA));
/* No changeset processing needed in this case. */
} else {
dbg_ddns_detail("No SOA in node, ignoring.\n");
/* If there is no SOA in the node, ignore. */
......@@ -824,28 +798,15 @@ static int knot_ddns_process_add_soa(knot_node_t *node,
/*----------------------------------------------------------------------------*/
static int knot_ddns_add_rr_new_normal(knot_node_t *node, knot_rrset_t *rr_copy,
knot_changes_t *changes)
static int knot_ddns_add_rr_new_normal(knot_node_t *node, knot_rrset_t *rr_copy)
{
assert(node != NULL);
assert(rr_copy != NULL);
assert(changes != NULL);
dbg_ddns_verb("Adding normal RR.\n");
/* Add the RRSet to 'changes'. */
int ret = knot_changes_add_rrset(changes, rr_copy, KNOT_CHANGES_NEW);
if (ret != KNOT_EOK) {
knot_rrset_free(&rr_copy, NULL);
dbg_ddns("Failed to store copy of the added RR: "
"%s\n", knot_strerror(ret));
return ret;
}
/* Add the RRSet to the node. */
ret = knot_node_add_rrset_no_merge(node, rr_copy);
int ret = knot_node_add_rrset_no_merge(node, rr_copy);
if (ret != KNOT_EOK) {
knot_rrset_free(&rr_copy, NULL);
dbg_ddns("Failed to add RR to node: %s\n", knot_strerror(ret));
return ret;
}
......@@ -898,11 +859,10 @@ static int knot_ddns_add_rr_merge_normal(knot_rrset_t *node_rrset_copy,
/*----------------------------------------------------------------------------*/
static int knot_ddns_add_rr(knot_node_t *node, const knot_rrset_t *rr,
knot_changes_t *changes, knot_rrset_t **rr_copy)
knot_rrset_t **rr_copy)
{
assert(node != NULL);
assert(rr != NULL);
assert(changes != NULL);
assert(rr_copy != NULL);
/* Copy the RRSet from the packet. */
......@@ -919,7 +879,7 @@ static int knot_ddns_add_rr(knot_node_t *node, const knot_rrset_t *rr,
* This code is more or less copied from xfr-in.c.
*/
knot_rrset_t *node_rrset_copy = NULL;
ret = xfrin_copy_rrset(node, rr->type, &node_rrset_copy, changes, 0);
ret = xfrin_copy_rrset(node, rr->type, &node_rrset_copy);
if (ret < 0) {
dbg_ddns("Failed to copy RRSet: %s\n", knot_strerror(ret));
knot_rrset_free(rr_copy, NULL);
......@@ -929,8 +889,7 @@ static int knot_ddns_add_rr(knot_node_t *node, const knot_rrset_t *rr,
if (node_rrset_copy == NULL) {
/* No such RRSet in the node. Add the whole UPDATE RRSet. */
dbg_ddns_detail("Adding whole UPDATE RR to the zone.\n");
ret = knot_ddns_add_rr_new_normal(node, *rr_copy,
changes);
ret = knot_ddns_add_rr_new_normal(node, *rr_copy);
if (ret != KNOT_EOK) {
dbg_ddns("Failed to add new RR to node.\n");
return ret;
......@@ -946,16 +905,6 @@ static int knot_ddns_add_rr(knot_node_t *node, const knot_rrset_t *rr,
knot_rrset_free(&node_rrset_copy, NULL);
return ret;
}
// save the new RRSet together with the new RDATA to 'changes'
// do not overwrite 'ret', it have to be returned
int r = knot_changes_add_rrset(changes, node_rrset_copy,
KNOT_CHANGES_NEW);
if (r != KNOT_EOK) {
dbg_ddns("Failed to store RRSet copy to 'changes'\n");
knot_rrset_free(&node_rrset_copy, NULL);
return r;
}
}
assert(ret >= 0);
......@@ -1023,14 +972,12 @@ static int knot_ddns_process_add(const knot_rrset_t *rr,
knot_node_t **node,
knot_zone_contents_t *zone,
knot_changeset_t *changeset,
knot_changes_t *changes,
knot_rrset_t **rr_copy)
{