Commit 525a5814 authored by Jan Kadlec's avatar Jan Kadlec

ixfr: fixed outgoing multimessage IXFRs with new changeset.

parent 6881e013
......@@ -25,6 +25,7 @@ enum ixfr_states {
struct ixfr_proc {
struct xfr_proc proc; /* Generic transfer processing context. */
changeset_iter_t cur; /* Current changeset iteration state.*/
knot_rrset_t cur_rr; /* Currently processed RRSet. */
int state; /* IXFR-in state. */
knot_rrset_t *final_soa; /* First SOA received via IXFR. */
list_t changesets; /* Processed changesets. */
......@@ -53,11 +54,13 @@ static int ixfr_put_chg_part(knot_pkt_t *pkt, struct ixfr_proc *ixfr, changeset_
assert(ixfr);
assert(itt);
knot_rrset_t rr = changeset_iter_next(itt);
if (knot_rrset_empty(&ixfr->cur_rr)) {
ixfr->cur_rr = changeset_iter_next(itt);
}
int ret = KNOT_EOK; // Declaration for IXFR_SAFE_PUT macro
while(!knot_rrset_empty(&rr)) {
IXFR_SAFE_PUT(pkt, &rr);
rr = changeset_iter_next(itt);
while(!knot_rrset_empty(&ixfr->cur_rr)) {
IXFR_SAFE_PUT(pkt, &ixfr->cur_rr);
ixfr->cur_rr = changeset_iter_next(itt);
}
return ret;
......@@ -86,7 +89,7 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Put REMOVE RRSets. */
if (ixfr->state == IXFR_DEL) {
if (EMPTY_LIST(ixfr->cur.iters)) {
if (EMPTY_LIST(ixfr->cur.iters) && knot_rrset_empty(&ixfr->cur_rr)) {
changeset_iter_rem(&ixfr->cur, chgset, false);
}
ret = ixfr_put_chg_part(pkt, ixfr, &ixfr->cur);
......@@ -104,9 +107,9 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
ixfr->state = IXFR_ADD;
}
/* Put REMOVE RRSets. */
/* Put Add RRSets. */
if (ixfr->state == IXFR_ADD) {
if (EMPTY_LIST(ixfr->cur.iters)) {
if (EMPTY_LIST(ixfr->cur.iters) && knot_rrset_empty(&ixfr->cur_rr)) {
changeset_iter_add(&ixfr->cur, chgset, false);
}
ret = ixfr_put_chg_part(pkt, ixfr, &ixfr->cur);
......@@ -223,6 +226,7 @@ static int ixfr_answer_init(struct query_data *qdata)
init_list(&xfer->proc.nodes);
init_list(&xfer->changesets);
init_list(&xfer->cur.iters);
knot_rrset_init_empty(&xfer->cur_rr);
add_tail_list(&xfer->changesets, &chgsets);
xfer->qdata = qdata;
......
......@@ -28,6 +28,19 @@
#include "libknot/rrtype/soa.h"
#include "common/debug.h"
static int add_rr_to_zone(zone_contents_t *z, const knot_rrset_t *rrset)
{
zone_node_t *n = NULL;
int ret = zone_contents_add_rr(z, rrset, &n);
UNUSED(n);
if (ret != KNOT_ETTL) {
return ret;
} else {
// Ignore TTL errors
return KNOT_EOK;
}
}
void changeset_init(changeset_t *ch, const knot_dname_t *apex, mm_ctx_t *mm)
{
memset(ch, 0, sizeof(changeset_t));
......@@ -57,18 +70,12 @@ changeset_t *changeset_new(mm_ctx_t *mm, const knot_dname_t *apex)
int changeset_add_rrset(changeset_t *ch, const knot_rrset_t *rrset)
{
zone_node_t *n = NULL;
int ret = zone_contents_add_rr(ch->add, rrset, &n);
UNUSED(n);
return ret;
return add_rr_to_zone(ch->add, rrset);
}
int changeset_rem_rrset(changeset_t *ch, const knot_rrset_t *rrset)
{
zone_node_t *n = NULL;
int ret = zone_contents_add_rr(ch->remove, rrset, &n);
UNUSED(n);
return ret;
return add_rr_to_zone(ch->remove, rrset);
}
bool changeset_empty(const changeset_t *ch)
......@@ -80,6 +87,7 @@ bool changeset_empty(const changeset_t *ch)
if (ch->soa_to) {
return false;
}
changeset_iter_t itt;
changeset_iter_all(&itt, ch, false);
......@@ -94,6 +102,7 @@ size_t changeset_size(const changeset_t *ch)
if (ch == NULL) {
return 0;
}
changeset_iter_t itt;
changeset_iter_all(&itt, ch, false);
......
......@@ -873,7 +873,7 @@ static uint16_t ret_to_rcode(int ret)
{
if (ret == KNOT_EMALF) {
return KNOT_RCODE_FORMERR;
} else if (ret == KNOT_EDENIED || ret == KNOT_ETTL) {
} else if (ret == KNOT_EDENIED) {
return KNOT_RCODE_REFUSED;
} else {
return KNOT_RCODE_SERVFAIL;
......
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