"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/knot/updates/changesets.c" between
knot-2.9.1.tar.xz and knot-2.9.2.tar.xz

About: Knot DNS is a high-performance authoritative-only DNS server (supports zone transfers, dynamic updates and DNSSEC).

changesets.c  (knot-2.9.1.tar.xz):changesets.c  (knot-2.9.2.tar.xz)
skipping to change at line 159 skipping to change at line 159
if (changeset_init(ret, apex) == KNOT_EOK) { if (changeset_init(ret, apex) == KNOT_EOK) {
return ret; return ret;
} else { } else {
free(ret); free(ret);
return NULL; return NULL;
} }
} }
bool changeset_empty(const changeset_t *ch) bool changeset_empty(const changeset_t *ch)
{ {
if (ch == NULL || ch->add == NULL || ch->remove == NULL) { if (ch == NULL) {
return true; return true;
} }
if (ch->soa_to) { if (zone_contents_is_empty(ch->remove) &&
return false; zone_contents_is_empty(ch->add)) {
if (ch->soa_to == NULL) {
return true;
}
if (ch->soa_from != NULL && ch->soa_to != NULL &&
knot_rrset_equal(ch->soa_from, ch->soa_to, false)) {
return true;
}
} }
changeset_iter_t itt; return false;
changeset_iter_all(&itt, ch);
knot_rrset_t rr = changeset_iter_next(&itt);
changeset_iter_clear(&itt);
return knot_rrset_empty(&rr);
} }
size_t changeset_size(const changeset_t *ch) size_t changeset_size(const changeset_t *ch)
{ {
if (ch == NULL) { if (ch == NULL) {
return 0; return 0;
} }
changeset_iter_t itt; changeset_iter_t itt;
changeset_iter_all(&itt, ch); changeset_iter_all(&itt, ch);
skipping to change at line 360 skipping to change at line 361
uint32_t changeset_from(const changeset_t *ch) uint32_t changeset_from(const changeset_t *ch)
{ {
return ch->soa_from == NULL ? 0 : knot_soa_serial(ch->soa_from->rrs.rdata ); return ch->soa_from == NULL ? 0 : knot_soa_serial(ch->soa_from->rrs.rdata );
} }
uint32_t changeset_to(const changeset_t *ch) uint32_t changeset_to(const changeset_t *ch)
{ {
return ch->soa_to == NULL ? 0 : knot_soa_serial(ch->soa_to->rrs.rdata); return ch->soa_to == NULL ? 0 : knot_soa_serial(ch->soa_to->rrs.rdata);
} }
typedef struct {
const zone_contents_t *zone;
changeset_t *fixing;
knot_mm_t *mm;
} preapply_fix_ctx;
static int preapply_fix_rrset(const knot_rrset_t *apply, bool adding, void *data
)
{
preapply_fix_ctx *ctx = (preapply_fix_ctx *)data;
const zone_node_t *znode = zone_contents_find_node(ctx->zone, apply->owne
r);
const knot_rdataset_t *zrdataset = node_rdataset(znode, apply->type);
if (adding && zrdataset == NULL) {
return KNOT_EOK;
}
knot_rrset_t *fixrrset;
if (adding) {
fixrrset = knot_rrset_new(apply->owner, apply->type, apply->rclas
s,
apply->ttl, ctx->mm);
} else {
fixrrset = knot_rrset_copy(apply, ctx->mm);
}
if (fixrrset == NULL) {
return KNOT_ENOMEM;
}
int ret = KNOT_EOK;
if (adding) {
ret = knot_rdataset_intersect(zrdataset, &apply->rrs, &fixrrset->
rrs, ctx->mm);
} else {
uint32_t zrrset_ttl = node_rrset(znode, apply->type).ttl;
if (zrdataset != NULL && fixrrset->ttl == zrrset_ttl) {
ret = knot_rdataset_subtract(&fixrrset->rrs, zrdataset, c
tx->mm);
}
}
if (ret == KNOT_EOK && !knot_rrset_empty(fixrrset)) {
if (adding) {
ret = changeset_add_removal(ctx->fixing, fixrrset, 0);
} else {
ret = changeset_add_addition(ctx->fixing, fixrrset, 0);
}
}
knot_rrset_free(fixrrset, ctx->mm);
return ret;
}
static int subtract_callback(const knot_rrset_t *rrset, bool addition, void *sub
tractfrom)
{
changeset_t *chsf = (changeset_t *)subtractfrom;
if (addition) {
return changeset_remove_removal(chsf, rrset);
} else {
return changeset_remove_addition(chsf, rrset);
}
}
static int subtract(changeset_t *from, const changeset_t *what)
{
return changeset_walk(what, subtract_callback, (void *)from);
}
int changeset_preapply_fix(const zone_contents_t *zone, changeset_t *ch)
{
if (zone == NULL || ch == NULL) {
return KNOT_EINVAL;
}
changeset_t fixing;
int ret = changeset_init(&fixing, zone->apex->owner);
if (ret != KNOT_EOK) {
return ret;
}
preapply_fix_ctx ctx = { .zone = zone, .fixing = &fixing, .mm = NULL };
ret = changeset_walk(ch, preapply_fix_rrset, (void *)&ctx);
if (ret == KNOT_EOK) {
ret = subtract(ch, &fixing);
}
changeset_clear(&fixing);
return ret;
}
int changeset_cancelout(changeset_t *ch)
{
if (ch == NULL) {
return KNOT_EINVAL;
}
changeset_t fixing;
int ret = changeset_init(&fixing, ch->add->apex->owner);
if (ret != KNOT_EOK) {
return ret;
}
preapply_fix_ctx ctx = { .zone = ch->remove, .fixing = &fixing, .mm = NUL
L };
ret = changeset_walk(ch, preapply_fix_rrset, (void *)&ctx);
if (ret == KNOT_EOK) {
assert(zone_contents_is_empty(fixing.add));
zone_contents_t *fixing_add_bck = fixing.add;
fixing.add = fixing.remove;
ret = subtract(ch, &fixing);
fixing.add = fixing_add_bck;
}
changeset_clear(&fixing);
return ret;
}
bool changeset_differs_just_serial(const changeset_t *ch) bool changeset_differs_just_serial(const changeset_t *ch)
{ {
if (ch == NULL || ch->soa_from == NULL || ch->soa_to == NULL) { if (ch == NULL || ch->soa_from == NULL || ch->soa_to == NULL) {
return false; return false;
} }
knot_rrset_t *soa_to_cpy = knot_rrset_copy(ch->soa_to, NULL); knot_rrset_t *soa_to_cpy = knot_rrset_copy(ch->soa_to, NULL);
knot_soa_serial_set(soa_to_cpy->rrs.rdata, knot_soa_serial(ch->soa_from-> rrs.rdata)); knot_soa_serial_set(soa_to_cpy->rrs.rdata, knot_soa_serial(ch->soa_from-> rrs.rdata));
bool ret = knot_rrset_equal(ch->soa_from, soa_to_cpy, true); bool ret = knot_rrset_equal(ch->soa_from, soa_to_cpy, true);
 End of changes. 4 change blocks. 
125 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)