Commit 8ebd8667 authored by Daniel Salzman's avatar Daniel Salzman

Adapt to new rrtype and rdataset API

parent 5060f153
...@@ -182,7 +182,7 @@ static int zone_status(zone_t *zone, ctl_args_t *args) ...@@ -182,7 +182,7 @@ static int zone_status(zone_t *zone, ctl_args_t *args)
if (zone->contents != NULL) { if (zone->contents != NULL) {
knot_rdataset_t *soa = node_rdataset(zone->contents->apex, knot_rdataset_t *soa = node_rdataset(zone->contents->apex,
KNOT_RRTYPE_SOA); KNOT_RRTYPE_SOA);
ret = snprintf(buff, sizeof(buff), "%u", knot_soa_serial(soa)); ret = snprintf(buff, sizeof(buff), "%u", knot_soa_serial(soa->rdata));
} else { } else {
ret = snprintf(buff, sizeof(buff), "none"); ret = snprintf(buff, sizeof(buff), "none");
} }
......
...@@ -100,7 +100,7 @@ static int ds_query_consume(knot_layer_t *layer, knot_pkt_t *pkt) ...@@ -100,7 +100,7 @@ static int ds_query_consume(knot_layer_t *layer, knot_pkt_t *pkt)
return KNOT_STATE_FAIL; return KNOT_STATE_FAIL;
} }
if (match_key_ds(data->key, knot_rdataset_at(&rr->rrs, 0))) { if (match_key_ds(data->key, rr->rrs.rdata)) {
match = true; match = true;
break; break;
} }
......
...@@ -370,14 +370,13 @@ static zone_node_t *create_nsec3_node_for_node(const zone_node_t *node, ...@@ -370,14 +370,13 @@ static zone_node_t *create_nsec3_node_for_node(const zone_node_t *node,
static int connect_nsec3_base(knot_rdataset_t *a_rrs, const knot_dname_t *b_name) static int connect_nsec3_base(knot_rdataset_t *a_rrs, const knot_dname_t *b_name)
{ {
assert(a_rrs); assert(a_rrs);
uint8_t algorithm = knot_nsec3_algorithm(a_rrs, 0); uint8_t algorithm = knot_nsec3_alg(a_rrs->rdata);
if (algorithm == 0) { if (algorithm == 0) {
return KNOT_EINVAL; return KNOT_EINVAL;
} }
uint8_t *raw_hash = NULL; uint8_t raw_length = knot_nsec3_next_len(a_rrs->rdata);
uint8_t raw_length = 0; uint8_t *raw_hash = (uint8_t *)knot_nsec3_next(a_rrs->rdata);
knot_nsec3_next_hashed(a_rrs, 0, &raw_hash, &raw_length);
if (raw_hash == NULL) { if (raw_hash == NULL) {
return KNOT_EINVAL; return KNOT_EINVAL;
} }
...@@ -606,7 +605,8 @@ static int fix_nsec3_for_node(zone_update_t *update, const dnssec_nsec3_params_t ...@@ -606,7 +605,8 @@ static int fix_nsec3_for_node(zone_update_t *update, const dnssec_nsec3_params_t
ret = changeset_add_removal(chgset, &rem_rrsig, 0); ret = changeset_add_removal(chgset, &rem_rrsig, 0);
} }
} }
knot_nsec3_next_hashed(&rem_nsec3.rrs, 0, &next_hash, &next_length); next_hash = (uint8_t *)knot_nsec3_next(rem_nsec3.rrs.rdata);
next_length = knot_nsec3_next_len(rem_nsec3.rrs.rdata);
} }
} }
...@@ -621,9 +621,8 @@ static int fix_nsec3_for_node(zone_update_t *update, const dnssec_nsec3_params_t ...@@ -621,9 +621,8 @@ static int fix_nsec3_for_node(zone_update_t *update, const dnssec_nsec3_params_t
// copy hash of next element from removed record // copy hash of next element from removed record
if (next_hash != NULL) { if (next_hash != NULL) {
uint8_t *raw_hash = NULL; uint8_t *raw_hash = (uint8_t *)knot_nsec3_next(add_nsec3.rrs.rdata);
uint8_t raw_length = 0; uint8_t raw_length = knot_nsec3_next_len(add_nsec3.rrs.rdata);
knot_nsec3_next_hashed(&add_nsec3.rrs, 0, &raw_hash, &raw_length);
assert(raw_hash != NULL); assert(raw_hash != NULL);
if (raw_length != next_length) { if (raw_length != next_length) {
ret = KNOT_EMALF; ret = KNOT_EMALF;
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
static uint32_t zone_soa_min_ttl(const zone_contents_t *zone) static uint32_t zone_soa_min_ttl(const zone_contents_t *zone)
{ {
knot_rrset_t soa = node_rrset(zone->apex, KNOT_RRTYPE_SOA); knot_rrset_t soa = node_rrset(zone->apex, KNOT_RRTYPE_SOA);
return knot_soa_minimum(&soa.rrs); return knot_soa_minimum(soa.rrs.rdata);
} }
static uint32_t zone_soa_ttl(const zone_contents_t *zone) static uint32_t zone_soa_ttl(const zone_contents_t *zone)
......
...@@ -285,15 +285,16 @@ int knot_synth_rrsig(uint16_t type, const knot_rdataset_t *rrsig_rrs, ...@@ -285,15 +285,16 @@ int knot_synth_rrsig(uint16_t type, const knot_rdataset_t *rrsig_rrs,
return KNOT_EINVAL; return KNOT_EINVAL;
} }
knot_rdata_t *rr_to_copy = rrsig_rrs->rdata;
for (int i = 0; i < rrsig_rrs->count; ++i) { for (int i = 0; i < rrsig_rrs->count; ++i) {
if (type == knot_rrsig_type_covered(rrsig_rrs, i)) { if (type == knot_rrsig_type_covered(rr_to_copy)) {
const knot_rdata_t *rr_to_copy = knot_rdataset_at(rrsig_rrs, i);
int ret = knot_rdataset_add(out_sig, rr_to_copy, mm); int ret = knot_rdataset_add(out_sig, rr_to_copy, mm);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
knot_rdataset_clear(out_sig, mm); knot_rdataset_clear(out_sig, mm);
return ret; return ret;
} }
} }
rr_to_copy = knot_rdataset_next(rr_to_copy);
} }
return out_sig->count > 0 ? KNOT_EOK : KNOT_ENOENT; return out_sig->count > 0 ? KNOT_EOK : KNOT_ENOENT;
...@@ -304,19 +305,17 @@ int knot_synth_rrsig(uint16_t type, const knot_rdataset_t *rrsig_rrs, ...@@ -304,19 +305,17 @@ int knot_synth_rrsig(uint16_t type, const knot_rdataset_t *rrsig_rrs,
/*! /*!
* \brief Check if the signature is expired. * \brief Check if the signature is expired.
* *
* \param rrsigs RR set with RRSIGs. * \param rrsig RRSIG rdata.
* \param pos Number of RR in the RR set.
* \param policy DNSSEC policy. * \param policy DNSSEC policy.
* *
* \return Signature is expired or should be replaced soon. * \return Signature is expired or should be replaced soon.
*/ */
static bool is_expired_signature(const knot_rrset_t *rrsigs, size_t pos, static bool is_expired_signature(const knot_rdata_t *rrsig, uint32_t now,
uint32_t now, uint32_t refresh_before) uint32_t refresh_before)
{ {
assert(!knot_rrset_empty(rrsigs)); assert(rrsig);
assert(rrsigs->type == KNOT_RRTYPE_RRSIG);
uint32_t expire_at = knot_rrsig_sig_expiration(&rrsigs->rrs, pos); uint32_t expire_at = knot_rrsig_sig_expiration(rrsig);
uint32_t expire_in = expire_at > now ? expire_at - now : 0; uint32_t expire_in = expire_at > now ? expire_at - now : 0;
return expire_in <= refresh_before; return expire_in <= refresh_before;
...@@ -333,21 +332,21 @@ int knot_check_signature(const knot_rrset_t *covered, ...@@ -333,21 +332,21 @@ int knot_check_signature(const knot_rrset_t *covered,
return KNOT_EINVAL; return KNOT_EINVAL;
} }
if (is_expired_signature(rrsigs, pos, dnssec_ctx->now, knot_rdata_t *rrsig = knot_rdataset_at(&rrsigs->rrs, pos);
assert(rrsig);
if (is_expired_signature(rrsig, dnssec_ctx->now,
dnssec_ctx->policy->rrsig_refresh_before)) { dnssec_ctx->policy->rrsig_refresh_before)) {
return DNSSEC_INVALID_SIGNATURE; return DNSSEC_INVALID_SIGNATURE;
} }
// identify fields in the signature being validated // identify fields in the signature being validated
uint8_t *rdata = knot_rdataset_at(&rrsigs->rrs, pos)->data; dnssec_binary_t signature = {
if (!rdata) { .size = knot_rrsig_signature_len(rrsig),
return KNOT_EINVAL; .data = (uint8_t *)knot_rrsig_signature(rrsig)
} };
if (signature.data == NULL) {
dnssec_binary_t signature = { 0 };
knot_rrsig_signature(&rrsigs->rrs, pos, &signature.data, &signature.size);
if (!signature.data) {
return KNOT_EINVAL; return KNOT_EINVAL;
} }
...@@ -358,7 +357,7 @@ int knot_check_signature(const knot_rrset_t *covered, ...@@ -358,7 +357,7 @@ int knot_check_signature(const knot_rrset_t *covered,
return result; return result;
} }
result = knot_sign_ctx_add_data(sign_ctx, rdata, covered); result = knot_sign_ctx_add_data(sign_ctx, rrsig->data, covered);
if (result != KNOT_EOK) { if (result != KNOT_EOK) {
return result; return result;
} }
......
...@@ -269,8 +269,8 @@ int knot_dnssec_sign_update(zone_update_t *update, zone_sign_reschedule_t *resch ...@@ -269,8 +269,8 @@ int knot_dnssec_sign_update(zone_update_t *update, zone_sign_reschedule_t *resch
goto done; goto done;
} }
bool soa_changed = (knot_soa_serial(node_rdataset(update->zone->contents->apex, KNOT_RRTYPE_SOA)) != bool soa_changed = (knot_soa_serial(node_rdataset(update->zone->contents->apex, KNOT_RRTYPE_SOA)->rdata) !=
knot_soa_serial(node_rdataset(update->new_cont->apex, KNOT_RRTYPE_SOA))); knot_soa_serial(node_rdataset(update->new_cont->apex, KNOT_RRTYPE_SOA)->rdata));
if (zone_update_no_change(update) && !soa_changed && if (zone_update_no_change(update) && !soa_changed &&
!knot_zone_sign_soa_expired(update->new_cont, &keyset, &ctx)) { !knot_zone_sign_soa_expired(update->new_cont, &keyset, &ctx)) {
......
...@@ -178,10 +178,9 @@ static bool nsec3param_valid(const knot_rdataset_t *rrs, ...@@ -178,10 +178,9 @@ static bool nsec3param_valid(const knot_rdataset_t *rrs,
return false; return false;
} }
knot_rdata_t *rrd = knot_rdataset_at(rrs, 0);
dnssec_binary_t rdata = { dnssec_binary_t rdata = {
.size = rrd->len, .size = rrs->rdata->len,
.data = rrd->data, .data = rrs->rdata->data,
}; };
dnssec_nsec3_params_t parsed = { 0 }; dnssec_nsec3_params_t parsed = { 0 };
...@@ -342,7 +341,7 @@ int knot_zone_create_nsec_chain(zone_update_t *update, ...@@ -342,7 +341,7 @@ int knot_zone_create_nsec_chain(zone_update_t *update,
return KNOT_EINVAL; return KNOT_EINVAL;
} }
uint32_t nsec_ttl = knot_soa_minimum(soa); uint32_t nsec_ttl = knot_soa_minimum(soa->rdata);
dnssec_nsec3_params_t params = nsec3param_init(ctx->policy, ctx->zone); dnssec_nsec3_params_t params = nsec3param_init(ctx->policy, ctx->zone);
changeset_t ch; changeset_t ch;
...@@ -409,8 +408,8 @@ int knot_zone_fix_nsec_chain(zone_update_t *update, ...@@ -409,8 +408,8 @@ int knot_zone_fix_nsec_chain(zone_update_t *update,
return KNOT_EINVAL; return KNOT_EINVAL;
} }
uint32_t nsec_ttl_old = knot_soa_minimum(soa_old); uint32_t nsec_ttl_old = knot_soa_minimum(soa_old->rdata);
uint32_t nsec_ttl_new = knot_soa_minimum(soa_new); uint32_t nsec_ttl_new = knot_soa_minimum(soa_new->rdata);
dnssec_nsec3_params_t params = nsec3param_init(ctx->policy, ctx->zone); dnssec_nsec3_params_t params = nsec3param_init(ctx->policy, ctx->zone);
changeset_t ch; changeset_t ch;
......
...@@ -111,9 +111,11 @@ static bool valid_signature_exists(const knot_rrset_t *covered, ...@@ -111,9 +111,11 @@ static bool valid_signature_exists(const knot_rrset_t *covered,
} }
uint16_t rrsigs_rdata_count = rrsigs->rrs.count; uint16_t rrsigs_rdata_count = rrsigs->rrs.count;
knot_rdata_t *rdata = rrsigs->rrs.rdata;
for (uint16_t i = 0; i < rrsigs_rdata_count; i++) { for (uint16_t i = 0; i < rrsigs_rdata_count; i++) {
uint16_t rr_keytag = knot_rrsig_key_tag(&rrsigs->rrs, i); uint16_t rr_keytag = knot_rrsig_key_tag(rdata);
uint16_t rr_covered = knot_rrsig_type_covered(&rrsigs->rrs, i); uint16_t rr_covered = knot_rrsig_type_covered(rdata);
rdata = knot_rdataset_next(rdata);
uint16_t keytag = dnssec_key_get_keytag(key); uint16_t keytag = dnssec_key_get_keytag(key);
if (rr_keytag != keytag || rr_covered != covered->type) { if (rr_keytag != keytag || rr_covered != covered->type) {
...@@ -200,40 +202,18 @@ static bool all_signatures_exist(const knot_rrset_t *covered, ...@@ -200,40 +202,18 @@ static bool all_signatures_exist(const knot_rrset_t *covered,
return true; return true;
} }
/*!
* \brief Get zone key for given RRSIG (checks key tag only).
*
* \param rrsigs RR set with RRSIGs.
* \param pos Number of RR in RR set.
* \param keys Zone keys.
*
* \return Dynarray of such keys.
*/
static keyptr_dynarray_t get_matching_zone_keys(const knot_rrset_t *rrsigs,
size_t pos, const zone_keyset_t *keys)
{
assert(rrsigs && rrsigs->type == KNOT_RRTYPE_RRSIG);
assert(keys);
uint16_t keytag = knot_rrsig_key_tag(&rrsigs->rrs, pos);
return get_zone_keys(keys, keytag);
}
/*! /*!
* \brief Note earliest expiration of a signature. * \brief Note earliest expiration of a signature.
* *
* \param rrsigs RR set with RRSIGs. * \param rrsig RRSIG rdata.
* \param pos Position of RR in rrsigs.
* \param expires_at Current earliest expiration, will be updated. * \param expires_at Current earliest expiration, will be updated.
*/ */
static void note_earliest_expiration(const knot_rrset_t *rrsigs, size_t pos, static void note_earliest_expiration(const knot_rdata_t *rrsig, knot_time_t *expires_at)
knot_time_t *expires_at)
{ {
assert(rrsigs); assert(rrsig);
assert(expires_at); assert(expires_at);
uint32_t curr_rdata = knot_rrsig_sig_expiration(&rrsigs->rrs, pos); uint32_t curr_rdata = knot_rrsig_sig_expiration(rrsig);
knot_time_t current = knot_time_from_u32(curr_rdata); knot_time_t current = knot_time_from_u32(curr_rdata);
*expires_at = knot_time_min(current, *expires_at); *expires_at = knot_time_min(current, *expires_at);
} }
...@@ -280,7 +260,10 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered, ...@@ -280,7 +260,10 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered,
uint16_t rrsig_rdata_count = synth_rrsig.rrs.count; uint16_t rrsig_rdata_count = synth_rrsig.rrs.count;
for (uint16_t i = 0; i < rrsig_rdata_count; i++) { for (uint16_t i = 0; i < rrsig_rdata_count; i++) {
struct keyptr_dynarray keys = get_matching_zone_keys(&synth_rrsig, i, zone_keys); knot_rdata_t *rr = knot_rdataset_at(&synth_rrsig.rrs, i);
uint16_t keytag = knot_rrsig_key_tag(rr);
struct keyptr_dynarray keys = get_zone_keys(zone_keys, keytag);
int endloop = 0; // 1 - continue; 2 - break int endloop = 0; // 1 - continue; 2 - break
dynarray_foreach(keyptr, zone_key_t *, key, keys) { dynarray_foreach(keyptr, zone_key_t *, key, keys) {
...@@ -291,7 +274,7 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered, ...@@ -291,7 +274,7 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered,
(*key)->key, (*key)->ctx, dnssec_ctx); (*key)->key, (*key)->ctx, dnssec_ctx);
if (result == KNOT_EOK) { if (result == KNOT_EOK) {
// valid signature // valid signature
note_earliest_expiration(&synth_rrsig, i, expires_at); note_earliest_expiration(rr, expires_at);
endloop = 1; endloop = 1;
break; break;
} else if (result != DNSSEC_INVALID_SIGNATURE) { } else if (result != DNSSEC_INVALID_SIGNATURE) {
...@@ -311,8 +294,7 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered, ...@@ -311,8 +294,7 @@ static int remove_expired_rrsigs(const knot_rrset_t *covered,
to_remove = create_empty_rrsigs_for(&synth_rrsig); to_remove = create_empty_rrsigs_for(&synth_rrsig);
} }
knot_rdata_t *rr_rem = knot_rdataset_at(&synth_rrsig.rrs, i); result = knot_rdataset_add(&to_remove.rrs, rr, NULL);
result = knot_rdataset_add(&to_remove.rrs, rr_rem, NULL);
if (result != KNOT_EOK) { if (result != KNOT_EOK) {
break; break;
} }
...@@ -482,14 +464,14 @@ static int remove_standalone_rrsigs(const zone_node_t *node, ...@@ -482,14 +464,14 @@ static int remove_standalone_rrsigs(const zone_node_t *node,
} }
uint16_t rrsigs_rdata_count = rrsigs->rrs.count; uint16_t rrsigs_rdata_count = rrsigs->rrs.count;
knot_rdata_t *rdata = rrsigs->rrs.rdata;
for (uint16_t i = 0; i < rrsigs_rdata_count; ++i) { for (uint16_t i = 0; i < rrsigs_rdata_count; ++i) {
uint16_t type_covered = knot_rrsig_type_covered(&rrsigs->rrs, i); uint16_t type_covered = knot_rrsig_type_covered(rdata);
if (!node_rrtype_exists(node, type_covered)) { if (!node_rrtype_exists(node, type_covered)) {
knot_rrset_t to_remove; knot_rrset_t to_remove;
knot_rrset_init(&to_remove, rrsigs->owner, rrsigs->type, knot_rrset_init(&to_remove, rrsigs->owner, rrsigs->type,
rrsigs->rclass, rrsigs->ttl); rrsigs->rclass, rrsigs->ttl);
knot_rdata_t *rr_rem = knot_rdataset_at(&rrsigs->rrs, i); int ret = knot_rdataset_add(&to_remove.rrs, rdata, NULL);
int ret = knot_rdataset_add(&to_remove.rrs, rr_rem, NULL);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
return ret; return ret;
} }
...@@ -499,6 +481,7 @@ static int remove_standalone_rrsigs(const zone_node_t *node, ...@@ -499,6 +481,7 @@ static int remove_standalone_rrsigs(const zone_node_t *node,
return ret; return ret;
} }
} }
rdata = knot_rdataset_next(rdata);
} }
return KNOT_EOK; return KNOT_EOK;
......
...@@ -239,7 +239,7 @@ int event_load(conf_t *conf, zone_t *zone) ...@@ -239,7 +239,7 @@ int event_load(conf_t *conf, zone_t *zone)
// Schedule depedent events. // Schedule depedent events.
const knot_rdataset_t *soa = zone_soa(zone); const knot_rdataset_t *soa = zone_soa(zone);
zone->timers.soa_expire = knot_soa_expire(soa); zone->timers.soa_expire = knot_soa_expire(soa->rdata);
if (dnssec_enable) { if (dnssec_enable) {
event_dnssec_reschedule(conf, zone, &dnssec_refresh, false); // false since we handle NOTIFY below event_dnssec_reschedule(conf, zone, &dnssec_refresh, false); // false since we handle NOTIFY below
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -109,7 +109,7 @@ static int send_notify(conf_t *conf, zone_t *zone, const knot_rrset_t *soa, ...@@ -109,7 +109,7 @@ static int send_notify(conf_t *conf, zone_t *zone, const knot_rrset_t *soa,
if (ret == KNOT_EOK) { if (ret == KNOT_EOK) {
NOTIFY_LOG(LOG_INFO, zone->name, dst, NOTIFY_LOG(LOG_INFO, zone->name, dst,
"serial %u", knot_soa_serial(&soa->rrs)); "serial %u", knot_soa_serial(soa->rrs.rdata));
} else if (knot_pkt_ext_rcode(req->resp) == 0) { } else if (knot_pkt_ext_rcode(req->resp) == 0) {
NOTIFY_LOG(LOG_WARNING, zone->name, dst, NOTIFY_LOG(LOG_WARNING, zone->name, dst,
"failed (%s)", knot_strerror(ret)); "failed (%s)", knot_strerror(ret));
......
...@@ -420,15 +420,15 @@ static int ixfr_finalize(struct refresh_data *data) ...@@ -420,15 +420,15 @@ static int ixfr_finalize(struct refresh_data *data)
uint32_t old_serial = local_serial; uint32_t old_serial = local_serial;
changeset_t *chs = NULL; changeset_t *chs = NULL;
WALK_LIST(chs, data->ixfr.changesets) { WALK_LIST(chs, data->ixfr.changesets) {
master_serial = knot_soa_serial(&chs->soa_to->rrs); master_serial = knot_soa_serial(chs->soa_to->rrs.rdata);
knot_soa_serial_set(&chs->soa_from->rrs, local_serial); knot_soa_serial_set(chs->soa_from->rrs.rdata, local_serial);
if (have_lastsigned && (serial_compare(lastsigned_serial, local_serial) & SERIAL_MASK_GEQ)) { if (have_lastsigned && (serial_compare(lastsigned_serial, local_serial) & SERIAL_MASK_GEQ)) {
local_serial = lastsigned_serial; local_serial = lastsigned_serial;
} }
if (serial_compare(master_serial, local_serial) != SERIAL_GREATER) { if (serial_compare(master_serial, local_serial) != SERIAL_GREATER) {
conf_val_t val = conf_zone_get(data->conf, C_SERIAL_POLICY, data->zone->name); conf_val_t val = conf_zone_get(data->conf, C_SERIAL_POLICY, data->zone->name);
local_serial = serial_next(local_serial, conf_opt(&val)); local_serial = serial_next(local_serial, conf_opt(&val));
knot_soa_serial_set(&chs->soa_to->rrs, local_serial); knot_soa_serial_set(chs->soa_to->rrs.rdata, local_serial);
} else { } else {
local_serial = master_serial; local_serial = master_serial;
} }
...@@ -698,7 +698,7 @@ static enum xfr_type determine_xfr_type(const knot_pktsection_t *answer, ...@@ -698,7 +698,7 @@ static enum xfr_type determine_xfr_type(const knot_pktsection_t *answer,
if (answer->count == 1) { if (answer->count == 1) {
if (rr_one->type == KNOT_RRTYPE_SOA) { if (rr_one->type == KNOT_RRTYPE_SOA) {
return serial_is_current(zone_serial, knot_soa_serial(&rr_one->rrs)) ? return serial_is_current(zone_serial, knot_soa_serial(rr_one->rrs.rdata)) ?
XFR_TYPE_UPTODATE : XFR_TYPE_UNDETERMINED; XFR_TYPE_UPTODATE : XFR_TYPE_UNDETERMINED;
} }
return XFR_TYPE_ERROR; return XFR_TYPE_ERROR;
...@@ -731,7 +731,7 @@ static int ixfr_consume(knot_pkt_t *pkt, struct refresh_data *data) ...@@ -731,7 +731,7 @@ static int ixfr_consume(knot_pkt_t *pkt, struct refresh_data *data)
if (data->ixfr.proc == NULL) { if (data->ixfr.proc == NULL) {
const knot_pktsection_t *answer = knot_pkt_section(pkt, KNOT_ANSWER); const knot_pktsection_t *answer = knot_pkt_section(pkt, KNOT_ANSWER);
uint32_t master_serial = knot_soa_serial(&data->soa->rrs); uint32_t master_serial = knot_soa_serial(data->soa->rrs.rdata);
(void)zone_get_master_serial(data->zone, &master_serial); (void)zone_get_master_serial(data->zone, &master_serial);
data->xfr_type = determine_xfr_type(answer, master_serial, data->xfr_type = determine_xfr_type(answer, master_serial,
data->initial_soa_copy); data->initial_soa_copy);
...@@ -838,9 +838,9 @@ static int soa_query_consume(knot_layer_t *layer, knot_pkt_t *pkt) ...@@ -838,9 +838,9 @@ static int soa_query_consume(knot_layer_t *layer, knot_pkt_t *pkt)
return KNOT_STATE_FAIL; return KNOT_STATE_FAIL;
} }
uint32_t local_serial = knot_soa_serial(&data->soa->rrs); uint32_t local_serial = knot_soa_serial(data->soa->rrs.rdata);
(void)zone_get_master_serial(data->zone, &local_serial); (void)zone_get_master_serial(data->zone, &local_serial);
uint32_t remote_serial = knot_soa_serial(&rr->rrs); uint32_t remote_serial = knot_soa_serial(rr->rrs.rdata);
bool current = serial_is_current(local_serial, remote_serial); bool current = serial_is_current(local_serial, remote_serial);
bool master_uptodate = serial_is_current(remote_serial, local_serial); bool master_uptodate = serial_is_current(remote_serial, local_serial);
...@@ -876,7 +876,7 @@ static int transfer_produce(knot_layer_t *layer, knot_pkt_t *pkt) ...@@ -876,7 +876,7 @@ static int transfer_produce(knot_layer_t *layer, knot_pkt_t *pkt)
knot_rrset_free(sending_soa, data->mm); knot_rrset_free(sending_soa, data->mm);
return KNOT_STATE_FAIL; return KNOT_STATE_FAIL;
} }
knot_soa_serial_set(&sending_soa->rrs, master_serial); knot_soa_serial_set(sending_soa->rrs.rdata, master_serial);
knot_pkt_begin(pkt, KNOT_AUTHORITY); knot_pkt_begin(pkt, KNOT_AUTHORITY);
knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, sending_soa, 0); knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, sending_soa, 0);
knot_rrset_free(sending_soa, data->mm); knot_rrset_free(sending_soa, data->mm);
...@@ -1114,13 +1114,13 @@ int event_refresh(conf_t *conf, zone_t *zone) ...@@ -1114,13 +1114,13 @@ int event_refresh(conf_t *conf, zone_t *zone)
const knot_rdataset_t *soa = zone_soa(zone); const knot_rdataset_t *soa = zone_soa(zone);
if (ret == KNOT_EOK) { if (ret == KNOT_EOK) {
zone->timers.soa_expire = knot_soa_expire(soa); zone->timers.soa_expire = knot_soa_expire(soa->rdata);
zone->timers.last_refresh = now; zone->timers.last_refresh = now;
zone->timers.next_refresh = now + knot_soa_refresh(soa); zone->timers.next_refresh = now + knot_soa_refresh(soa->rdata);
} else { } else {
time_t next = 0; time_t next = 0;
if (soa) { if (soa) {
next = knot_soa_retry(soa); next = knot_soa_retry(soa->rdata);
} else { } else {
next = bootstrap_next(&zone->timers); next = bootstrap_next(&zone->timers);
} }
......
...@@ -1003,7 +1003,7 @@ int journal_load_bootstrap(journal_t *j, list_t *dst) ...@@ -1003,7 +1003,7 @@ int journal_load_bootstrap(journal_t *j, list_t *dst)
goto jlb_end; goto jlb_end;
} }
add_tail(dst, &bch->n); add_tail(dst, &bch->n);
uint32_t from = knot_soa_serial(&bch->soa_to->rrs); uint32_t from = knot_soa_serial(bch->soa_to->rrs.rdata);
uint32_t ls = txn->shadow_md.last_serial; uint32_t ls = txn->shadow_md.last_serial;
iterate(j, txn, load_list_itercb, JOURNAL_ITERATION_CHANGESETS, &dst, iterate(j, txn, load_list_itercb, JOURNAL_ITERATION_CHANGESETS, &dst,
...@@ -1286,7 +1286,7 @@ static int merge_unflushed_changesets(journal_t *j, txn_t *_txn, changeset_t **m ...@@ -1286,7 +1286,7 @@ static int merge_unflushed_changesets(journal_t *j, txn_t *_txn, changeset_t **m
txn->ret = load_one(j, txn, from, mch); txn->ret = load_one(j, txn, from, mch);
if (!was_merged && was_flushed && txn->ret == KNOT_EOK) { if (!was_merged && was_flushed && txn->ret == KNOT_EOK) {
// we have to jump to ONE AFTER last_flushed // we have to jump to ONE AFTER last_flushed
from = knot_soa_serial(&(*mch)->soa_to->rrs); from = knot_soa_serial((*mch)->soa_to->rrs.rdata);
changeset_free(*mch); changeset_free(*mch);
*mch = NULL; *mch = NULL;
txn->ret = load_one(j, txn, from, mch); txn->ret = load_one(j, txn, from, mch);
...@@ -1295,7 +1295,7 @@ static int merge_unflushed_changesets(journal_t *j, txn_t *_txn, changeset_t **m ...@@ -1295,7 +1295,7 @@ static int merge_unflushed_changesets(journal_t *j, txn_t *_txn, changeset_t **m
if (txn->ret != KNOT_EOK) { if (txn->ret != KNOT_EOK) {
goto m_u_ch_end; goto m_u_ch_end;
} }
from = knot_soa_serial(&(*mch)->soa_to->rrs); from = knot_soa_serial((*mch)->soa_to->rrs.rdata);
if (!serial_equal(from, txn->shadow_md.last_serial_to)) { if (!serial_equal(from, txn->shadow_md.last_serial_to)) {
txn->ret = iterate(j, txn, merge_itercb, JOURNAL_ITERATION_CHANGESETS, txn->ret = iterate(j, txn, merge_itercb, JOURNAL_ITERATION_CHANGESETS,
...@@ -1437,7 +1437,7 @@ static int store_changesets(journal_t *j, list_t *changesets) ...@@ -1437,7 +1437,7 @@ static int store_changesets(journal_t *j, list_t *changesets)
// PART 4: continuity and duplicity check // PART 4: continuity and duplicity check
changeset_t * chs_head = (HEAD(*changesets)); changeset_t * chs_head = (HEAD(*changesets));
bool is_first_bootstrap = (chs_head->soa_from == NULL); bool is_first_bootstrap = (chs_head->soa_from == NULL);
uint32_t serial = is_first_bootstrap ? 0 : knot_soa_serial(&chs_head->soa_from->rrs); uint32_t serial = is_first_bootstrap ? 0 : knot_soa_serial(chs_head->soa_from->rrs.rdata);
if (md_flag(txn, SERIAL_TO_VALID) && (is_first_bootstrap || if (md_flag(txn, SERIAL_TO_VALID) && (is_first_bootstrap ||
!serial_equal(txn->shadow_md.last_serial_to, serial)) && !serial_equal(txn->shadow_md.last_serial_to, serial)) &&
!inserting_bootstrap /* if inserting bootstrap, drop_journal() was called, so no discontinuity */) { !inserting_bootstrap /* if inserting bootstrap, drop_journal() was called, so no discontinuity */) {
...@@ -1455,7 +1455,7 @@ static int store_changesets(journal_t *j, list_t *changesets) ...@@ -1455,7 +1455,7 @@ static int store_changesets(journal_t *j, list_t *changesets)
txn_restart(txn); txn_restart(txn);
} }
WALK_LIST(ch, *changesets) { WALK_LIST(ch, *changesets) {
uint32_t serial_to = knot_soa_serial(&ch->soa_to->rrs); uint32_t serial_to = knot_soa_serial(ch->soa_to->rrs.rdata);
bool is_this_bootstrap = (ch->soa_from == NULL); bool is_this_bootstrap = (ch->soa_from == NULL);
bool is_this_merged = (inserting_merged && ch == TAIL(*changesets)); bool is_this_merged = (inserting_merged && ch == TAIL(*changesets));
if (is_this_bootstrap || is_this_merged) { if (is_this_bootstrap || is_this_merged) {
...@@ -1497,8 +1497,8 @@ static int store_changesets(journal_t *j, list_t *changesets) ...@@ -1497,8 +1497,8 @@ static int store_changesets(journal_t *j, list_t *changesets)
bool is_this_merged = (inserting_merged && ch == TAIL(*changesets)); bool is_this_merged = (inserting_merged && ch == TAIL(*changesets));
bool is_this_bootstrap = (ch->soa_from == NULL); bool is_this_bootstrap = (ch->soa_from == NULL);
uint32_t serial = is_this_bootstrap ? 0 : knot_soa_serial(&ch->soa_from->rrs); uint32_t serial = is_this_bootstrap ? 0 : knot_soa_serial(ch->soa_from->rrs.rdata);
uint32_t serial_to = knot_soa_serial(&ch->soa_to->rrs); uint32_t serial_to = knot_soa_serial(ch->soa_to->rrs.rdata);
while (serialize_unfinished(sctx)) { while (serialize_unfinished(sctx)) {
size_t chunk_size; size_t chunk_size;
...@@ -2088,7 +2088,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level) ...@@ -2088,7 +2088,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level)
ret = load_bootstrap_changeset(j, txn, &ch); ret = load_bootstrap_changeset(j, txn, &ch);
switch (ret) { switch (ret) {
case KNOT_EOK: case KNOT_EOK:
sto = knot_soa_serial(&ch->soa_to->rrs); sto = knot_soa_serial(ch->soa_to->rrs.rdata);
jch_info("bootstrap changeset loaded, sto %u", sto); jch_info("bootstrap changeset loaded, sto %u", sto);
changeset_free(ch); changeset_free(ch);
break; break;
...@@ -2108,7 +2108,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level) ...@@ -2108,7 +2108,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level)
goto check_merged; goto check_merged;
} }
sfrom = knot_soa_serial(&ch->soa_from->rrs), sto = knot_soa_serial(&ch->soa_to->rrs); sfrom = knot_soa_serial(ch->soa_from->rrs.rdata), sto = knot_soa_serial(ch->soa_to->rrs.rdata);
if (!serial_equal(txn->shadow_md.first_serial, sfrom)) { if (!serial_equal(txn->shadow_md.first_serial, sfrom)) {
jch_warn("first changeset's serial 'from' %u is not ok", sfrom); jch_warn("first changeset's serial 'from' %u is not ok", sfrom);
} }
...@@ -2120,7 +2120,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level) ...@@ -2120,7 +2120,7 @@ int journal_check(journal_t *j, journal_check_level_t warn_level)
jch_warn("can't read last flushed changeset %u (%s)",