Commit 6f647a6f authored by Vitezslav Kriz's avatar Vitezslav Kriz

zone-size-limit: remove clone conf

parent cd5c5664
......@@ -266,7 +266,6 @@ static void axfr_answer_cleanup(struct answer_data *data)
struct xfr_proc *proc = data->ext;
if (proc) {
zone_contents_deep_free(&proc->contents);
conf_free(proc->conf);
mm_free(data->mm, proc);
data->ext = NULL;
}
......@@ -283,25 +282,16 @@ static int axfr_answer_init(struct answer_data *data)
return KNOT_ENOMEM;
}
conf_t *conf;
int ret = conf_clone(&conf);
if (ret != KNOT_EOK) {
zone_contents_deep_free(&new_contents);
return ret;
}
/* Create new processing context. */
struct xfr_proc *proc = mm_alloc(data->mm, sizeof(struct xfr_proc));
if (proc == NULL) {
zone_contents_deep_free(&new_contents);
conf_free(conf);
return KNOT_ENOMEM;
}
memset(proc, 0, sizeof(struct xfr_proc));
proc->contents = new_contents;
gettimeofday(&proc->tstamp, NULL);
proc->conf = conf;
/* Set up cleanup callback. */
data->ext = proc;
......@@ -333,7 +323,7 @@ static int axfr_answer_finalize(struct answer_data *adata)
return rc;
}
conf_val_t val = conf_zone_get(proc->conf, C_MAX_ZONE_SIZE,
conf_val_t val = conf_zone_get(adata->param->conf, C_MAX_ZONE_SIZE,
proc->contents->apex->owner);
int64_t size_limit = conf_int(&val);
......@@ -371,8 +361,9 @@ static int axfr_answer_finalize(struct answer_data *adata)
return KNOT_EOK;
}
static int axfr_answer_packet(knot_pkt_t *pkt, struct xfr_proc *proc)
static int axfr_answer_packet(knot_pkt_t *pkt, struct answer_data *adata)
{
struct xfr_proc *proc = adata->ext;
assert(pkt != NULL);
assert(proc != NULL);
......@@ -380,7 +371,7 @@ static int axfr_answer_packet(knot_pkt_t *pkt, struct xfr_proc *proc)
proc->npkts += 1;
proc->nbytes += pkt->size;
conf_val_t val = conf_zone_get(proc->conf, C_MAX_ZONE_SIZE,
conf_val_t val = conf_zone_get(adata->param->conf, C_MAX_ZONE_SIZE,
proc->contents->apex->owner);
int64_t size_limit = conf_int(&val);
......@@ -443,7 +434,7 @@ int axfr_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
}
/* Process answer packet. */
int ret = axfr_answer_packet(pkt, (struct xfr_proc *)adata->ext);
int ret = axfr_answer_packet(pkt, adata);
if (ret == KNOT_STATE_DONE) {
NS_NEED_TSIG_SIGNED(&adata->param->tsig_ctx, 0);
/* This was the last packet, finalize zone and publish it. */
......
......@@ -61,7 +61,6 @@ struct xfr_proc {
unsigned nbytes; /* Bytes processed. */
struct timeval tstamp; /* Start time. */
zone_contents_t *contents; /* Processed zone. */
conf_t *conf;
};
/*! \brief Generic transfer processing (reused for IXFR).
......
......@@ -50,8 +50,8 @@ struct ixfr_proc {
knot_rrset_t *final_soa; /* First SOA received via IXFR. */
list_t changesets; /* Processed changesets. */
size_t change_count; /* Count of changesets received. */
size_t add_size;
size_t del_size;
size_t add_size; /* Size of records to add */
size_t del_size; /* Size of records to remove */
zone_t *zone; /* Modified zone - for journal access. */
knot_mm_t *mm; /* Memory context for RR allocations. */
struct query_data *qdata;
......@@ -340,7 +340,6 @@ static void ixfrin_cleanup(struct answer_data *data)
if (proc) {
changesets_free(&proc->changesets);
knot_rrset_free(&proc->final_soa, proc->mm);
conf_free(proc->proc.conf);
mm_free(data->mm, proc);
data->ext = NULL;
}
......@@ -349,21 +348,13 @@ static void ixfrin_cleanup(struct answer_data *data)
/*! \brief Initializes IXFR-in processing context. */
static int ixfrin_answer_init(struct answer_data *data)
{
conf_t *conf;
int ret = conf_clone(&conf);
if (ret != KNOT_EOK) {
return ret;
}
struct ixfr_proc *proc = mm_alloc(data->mm, sizeof(struct ixfr_proc));
if (proc == NULL) {
conf_free(conf);
return KNOT_ENOMEM;
}
memset(proc, 0, sizeof(struct ixfr_proc));
gettimeofday(&proc->proc.tstamp, NULL);
proc->proc.conf = conf;
init_list(&proc->changesets);
......@@ -410,11 +401,11 @@ static int ixfrin_finalize(struct answer_data *adata)
return ret;
}
conf_val_t val = conf_zone_get(ixfr->proc.conf, C_MAX_ZONE_SIZE,
conf_val_t val = conf_zone_get(adata->param->conf, C_MAX_ZONE_SIZE,
ixfr->zone->name);
const int64_t size_limit = conf_int(&val);
if (new_contents->size > size_limit) { // secodary check
if (new_contents->size > size_limit) { // secondary check
IXFRIN_LOG(LOG_WARNING, "zone size exceeded, limit %ld", size_limit);
update_rollback(&a_ctx);
update_free_zone(&new_contents);
......@@ -633,7 +624,7 @@ static int process_ixfrin_packet(knot_pkt_t *pkt, struct answer_data *adata)
ixfr->proc.npkts += 1;
ixfr->proc.nbytes += pkt->size;
conf_val_t val = conf_zone_get(ixfr->proc.conf, C_MAX_ZONE_SIZE,
conf_val_t val = conf_zone_get(adata->param->conf, C_MAX_ZONE_SIZE,
ixfr->zone->name);
const int64_t size_limit = conf_int(&val);
const size_t zone_size = ixfr->zone->contents->size;
......
......@@ -1130,7 +1130,7 @@ bool zone_contents_is_empty(const zone_contents_t *zone)
return !zone || !node_rrtype_exists(zone->apex, KNOT_RRTYPE_SOA);
}
static int measure_size(const zone_node_t *node, void *data){
static int measure_size(zone_node_t *node, void *data){
size_t *size = data;
int rrset_count = node->rrset_count;
......
......@@ -283,7 +283,13 @@ bool zone_contents_is_signed(const zone_contents_t *zone);
*/
bool zone_contents_is_empty(const zone_contents_t *zone);
/*!
* \brief Measure zone contents size.
*
* Size is measured in uncompressed wire format. Measured size is saved into
* zone contents structure.
* \return Measured size
*/
size_t zone_contents_measure_size(zone_contents_t *zone);
/*! @} */
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