Commit cfa183e9 authored by Jan Kadlec's avatar Jan Kadlec

changesets: remove obsolete SOA setter

parent 3db928d9
......@@ -1394,8 +1394,6 @@ int knot_zone_sign_update_soa(const knot_rrset_t *soa,
changeset->soa_from = soa_from;
changeset->soa_to = soa_to;
changeset->serial_from = serial;
changeset->serial_to = new_serial;
return KNOT_EOK;
}
......
......@@ -124,7 +124,9 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Finished change set. */
struct query_data *qdata = ixfr->qdata; /*< Required for IXFROUT_LOG() */
IXFROUT_LOG(LOG_INFO, "Serial %u -> %u.", chgset->serial_from, chgset->serial_to);
const uint32_t serial_from = knot_soa_serial(&chgset->soa_from->rrs);
const uint32_t serial_to = knot_soa_serial(&chgset->soa_to->rrs);
IXFROUT_LOG(LOG_INFO, "Serial %u -> %u.", serial_from, serial_to);
return ret;
}
......@@ -386,7 +388,6 @@ static int solve_soa_del(const knot_rrset_t *rr, changesets_t *changesets,
if (change->soa_from == NULL) {
return KNOT_ENOMEM;
}
change->serial_from = knot_soa_serial(&rr->rrs);
return KNOT_EOK;
}
......@@ -399,7 +400,6 @@ static int solve_soa_add(const knot_rrset_t *rr, changeset_t *change, mm_ctx_t *
if (change->soa_to == NULL) {
return KNOT_ENOMEM;
}
change->serial_to = knot_soa_serial(&rr->rrs);
return KNOT_EOK;
}
......
......@@ -983,11 +983,7 @@ static int changesets_unpack(changeset_t *chs)
* be set, check it.
*/
assert(rrset->type == KNOT_RRTYPE_SOA);
assert(chs->serial_from == knot_soa_serial(&rrset->rrs));
ret = changeset_add_soa(chs, rrset, CHANGESET_REMOVE);
if (ret != KNOT_EOK) {
return ret;
}
chs->soa_from = rrset;
/* Read remaining RRSets */
int in_remove_section = 1;
......@@ -1006,8 +1002,7 @@ static int changesets_unpack(changeset_t *chs)
/* Move to ADD section if in REMOVE. */
if (in_remove_section) {
ret = changeset_add_soa(chs, rrset,
CHANGESET_ADD);
chs->soa_to = rrset;
in_remove_section = 0;
} else {
/* Final SOA. */
......@@ -1096,7 +1091,8 @@ static int changeset_pack(const changeset_t *chs, journal_t *j)
dbg_xfr("Saving changeset from %u to %u.\n",
chs->serial_from, chs->serial_to);
uint64_t k = ixfrdb_key_make(chs->serial_from, chs->serial_to);
uint64_t k = ixfrdb_key_make(knot_soa_serial(&chs->soa_from->rrs),
knot_soa_serial(&chs->soa_to->rrs));
/* Count the size of the entire changeset in serialized form. */
size_t entry_size = 0;
......@@ -1184,8 +1180,6 @@ static int load_changeset(journal_t *journal, journal_node_t *n, void *data)
}
/* Initialize changeset. */
chs->serial_from = journal_key_from(n->id);
chs->serial_to = journal_key_to(n->id);
chs->data = malloc(n->len);
if (!chs->data) {
return KNOT_ENOMEM;
......@@ -1226,7 +1220,7 @@ int journal_load_changesets(const char *path, changesets_t *dst,
/* Check for complete history. */
changeset_t *last = changesets_get_last(dst);
if (to != last->serial_to) {
if (to != knot_soa_serial(&last->soa_to->rrs)) {
return KNOT_ERANGE;
}
......
......@@ -316,7 +316,7 @@ static int apply_changeset(zone_contents_t *contents, changeset_t *chset,
// check if serial matches
const knot_rdataset_t *soa = node_rdataset(contents->apex, KNOT_RRTYPE_SOA);
if (soa == NULL || knot_soa_serial(soa) != chset->serial_from) {
if (soa == NULL || knot_soa_serial(soa) != knot_soa_serial(&chset->soa_from->rrs)) {
dbg_xfrin("SOA serials do not match!!\n");
return KNOT_EINVAL;
}
......
......@@ -162,34 +162,6 @@ int changeset_add_rrset(changeset_t *ch, knot_rrset_t *rrset,
return KNOT_EOK;
}
static void knot_changeset_store_soa(knot_rrset_t **chg_soa,
uint32_t *chg_serial, knot_rrset_t *soa)
{
*chg_soa = soa;
*chg_serial = knot_soa_serial(&soa->rrs);
}
int changeset_add_soa(changeset_t *ch, knot_rrset_t *soa,
changeset_part_t part)
{
if (ch == NULL || soa == NULL) {
return KNOT_EINVAL;
}
switch (part) {
case CHANGESET_ADD:
knot_changeset_store_soa(&ch->soa_to, &ch->serial_to, soa);
break;
case CHANGESET_REMOVE:
knot_changeset_store_soa(&ch->soa_from, &ch->serial_from, soa);
break;
default:
return KNOT_EINVAL;
}
return KNOT_EOK;
}
bool changeset_is_empty(const changeset_t *ch)
{
if (ch == NULL) {
......@@ -251,7 +223,6 @@ int changeset_merge(changeset_t *ch1, changeset_t *ch2)
// soa_to from the first changeset is redundant, delete it
knot_rrset_free(&ch1->soa_to, NULL);
ch1->soa_to = ch2->soa_to;
ch1->serial_to = ch2->serial_to;
return KNOT_EOK;
}
......
......@@ -44,8 +44,6 @@ typedef struct changeset {
list_t add; /*!< List of RRs to add. */
uint8_t *data; /*!< Serialized changeset. */
size_t size; /*!< Size of serialized changeset. */
uint32_t serial_from; /*!< SOA start serial. */
uint32_t serial_to; /*!< SOA destination serial. */
list_t old_data; /*!< Old data, to be freed after succesfull update. */
list_t new_data; /*!< New data, to be freed after failed update. */
} changeset_t;
......@@ -139,16 +137,6 @@ bool changesets_empty(const changesets_t *chs);
int changeset_add_rrset(changeset_t *ch, knot_rrset_t *rrset,
changeset_part_t part);
/*!
* \brief Adds a source/destination SOA RRSet to changeset.
*
* \param changeset Changeset to store SOA to.
* \param soa SOA RRSet to be stored to changeset.
* \param part To which part we store SOA (from = REMOVE, add = TO)
*/
int changeset_add_soa(changeset_t *ch, knot_rrset_t *soa,
changeset_part_t part);
/*!
* \brief Checks whether changeset is empty.
*
......
......@@ -657,7 +657,9 @@ static int process_add_soa(const zone_node_t *node,
return KNOT_ENOMEM;
}
return changeset_add_soa(changeset, soa_cpy, CHANGESET_ADD);
changeset->soa_to = soa_cpy;
return KNOT_EOK;
}
/*!< \brief Adds normal RR, ignores when CNAME exists in node. */
......@@ -984,12 +986,7 @@ int ddns_process_update(const zone_t *zone, const knot_pkt_t *query,
return KNOT_ENOMEM;
}
int ret = changeset_add_soa(changeset, soa_begin, CHANGESET_REMOVE);
if (ret != KNOT_EOK) {
*rcode = ret_to_rcode(ret);
return ret;
}
changeset->soa_from = soa_begin;
int64_t sn_old = zone_contents_serial(zone->contents);
/* Process all RRs the Authority (Update) section. */
......@@ -1000,7 +997,7 @@ int ddns_process_update(const zone_t *zone, const knot_pkt_t *query,
const knot_rrset_t *rr = &authority->rr[i];
/* Check if the entry is correct. */
ret = check_update(rr, query, rcode);
int ret = check_update(rr, query, rcode);
if (ret != KNOT_EOK) {
assert(*rcode != KNOT_RCODE_NOERROR);
return ret;
......@@ -1035,11 +1032,7 @@ int ddns_process_update(const zone_t *zone, const knot_pkt_t *query,
zone_contents_next_serial(zone->contents,
zone->conf->serial_policy);
knot_soa_serial_set(&soa_cpy->rrs, new_serial);
ret = changeset_add_soa(changeset, soa_cpy, CHANGESET_ADD);
if (ret != KNOT_EOK) {
*rcode = ret_to_rcode(ret);
return ret;
}
changeset->soa_to = soa_cpy;
}
*rcode = KNOT_RCODE_NOERROR;
......
......@@ -83,9 +83,6 @@ static int knot_zone_diff_load_soas(const zone_contents_t *zone1,
return KNOT_ENOMEM;
}
changeset->serial_from = soa_serial1;
changeset->serial_to = soa_serial2;
dbg_zonediff_verb("zone_diff: load_soas: SOAs diffed. (%"PRId64" -> %"PRId64")\n",
soa_serial1, soa_serial2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment