Commit 02a00a78 authored by Vitezslav Kriz's avatar Vitezslav Kriz Committed by Jan Včelák

move TTL from semantic check. fix memory leak.

parent 9e58d371
......@@ -40,7 +40,7 @@ This utility checks zone similar to knotc zonecheck, but without running server.
.INDENT 0.0
.TP
\fB\-o\fP, \fB\-\-origin\fP \fIorigin\fP
The zone origin. If not specified the name of file or name without .zone ending is assumed to be the origin.
The zone origin. If not specified the name of file or name without \(aq.zone\(aq ending is assumed to be the origin.
.TP
\fB\-v\fP, \fB\-\-verbose\fP
Enable debug output.
......
This diff is collapsed.
......@@ -46,7 +46,6 @@ enum zonechecks_errors {
ZC_ERR_MISSING_SOA,
ZC_ERR_MISSING_NS_DEL_POINT,
ZC_ERR_TTL_MISMATCH,
ZC_ERR_GENERIC_GENERAL_ERROR, /* Generic error delimiter. */
......@@ -148,11 +147,26 @@ void err_handler_deinit(err_handler_t *h);
* \retval KNOT_EOK on success.
* \retval KNOT_ENOMEM if memory error.
*/
int err_handler_handle_error(err_handler_t *handler,
int err_handler_node_error(err_handler_t *handler,
const zone_contents_t *zone,
const zone_node_t *node,
int error, const char *data);
/*!
* \brief Called when error has been encountered for entire zone.
*
* Will save error to list for future possibility to log it.
*
* \param handler Error handler.
* \param zname Zone name
* \param error Type of error.
*
* \retval KNOT_EOK on success.
* \retval KNOT_ENOMEM if memory error.
*/
int err_handler_zone_error(err_handler_t *handler, const knot_dname_t *zname,
int error);
/*!
* \brief Check zone for semantic errors.
*
......
......@@ -56,24 +56,20 @@ static int add_rdata_to_rr(knot_rrset_t *rrset, const zs_scanner_t *scanner)
scanner->r_ttl, NULL);
}
static void log_ttl_error(const zone_contents_t *zone, const zone_node_t *node,
const knot_rrset_t *rr)
static void log_ttl_error(const zcreator_t *zc, const zone_node_t *node,
const knot_rrset_t *rr, const knot_dname_t *zone_name)
{
err_handler_t err_handler;
err_handler_init(&err_handler);
// Prepare additional info string.
char info_str[64] = { '\0' };
// Prepare additional type string.
char type_str[16] = { '\0' };
knot_rrtype_to_string(rr->type, type_str, sizeof(type_str));
int ret = snprintf(info_str, sizeof(info_str), "record type %s",
type_str);
if (ret <= 0 || ret >= sizeof(info_str)) {
*info_str = '\0';
}
/*!< \todo REPLACE WITH FATAL ERROR for master. */
err_handler_handle_error(&err_handler, zone, node,
ZC_ERR_TTL_MISMATCH, info_str);
char *node_name = knot_dname_to_str_alloc(node->owner);
WARNING(zone_name, "RRSet TTLs mismatched, node '%s' (record type %s)",
node_name == NULL ? "?" : node_name,
type_str);
free(node_name);
}
static bool handle_err(zcreator_t *zc, const zone_node_t *node,
......@@ -89,7 +85,7 @@ static bool handle_err(zcreator_t *zc, const zone_node_t *node,
} else if (ret == KNOT_ETTL) {
free(rrname);
assert(node);
log_ttl_error(zc->z, node, rr);
log_ttl_error(zc, node, rr, zname);
// Fail if we're the master for this zone.
return !master;
} else {
......@@ -258,7 +254,7 @@ zone_contents_t *zonefile_load(zloader_t *loader)
}
if (!node_rrtype_exists(loader->creator->z->apex, KNOT_RRTYPE_SOA)) {
ERROR(zname, "no SOA record, file '%s'", loader->source);
err_handler_zone_error(&loader->err_handler, zname, ZC_ERR_MISSING_SOA);
goto fail;
}
......
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