Commit cbd1a88d authored by Jan Včelák's avatar Jan Včelák 🚀

zones: migrate to new logging API

parent ce9b448e
......@@ -44,10 +44,8 @@ static int init_dnssec_structs(const zone_contents_t *zone,
zone->apex->owner,
nsec3_enabled, zone_keys);
if (result != KNOT_EOK) {
char *zname = knot_dname_to_str(zone->apex->owner);
log_zone_error("DNSSEC: Zone %s - %s\n", zname,
log_zone_error(zone->apex->owner, "DNSSEC: Failed to load keys: %s\n",
knot_strerror(result));
free(zname);
knot_free_zone_keys(zone_keys);
return result;
}
......@@ -72,12 +70,9 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
assert(zone);
assert(out_ch);
char *msgpref = sprintf_alloc("DNSSEC: Zone %s -", zone_config->name);
if (msgpref == NULL) {
return KNOT_ENOMEM;
}
const knot_dname_t *zone_name = zone->apex->owner;
log_zone_info("DNSSEC: Zone %s - Signing started...\n", zone_config->name);
log_zone_info(zone_name, "DNSSEC: Signing started\n");
uint32_t new_serial = zone_contents_next_serial(zone, zone_config->serial_policy);
dbg_dnssec_verb("Changeset empty before generating NSEC chain: %d\n",
......@@ -90,7 +85,6 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
int result = init_dnssec_structs(zone, zone_config, &zone_keys, &policy,
soa_up, force);
if (result != KNOT_EOK) {
free(msgpref);
return result;
}
......@@ -98,9 +92,8 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_create_nsec_chain(zone, out_ch,
&zone_keys, &policy);
if (result != KNOT_EOK) {
log_zone_error("%s Could not create NSEC(3) chain (%s).\n",
msgpref, knot_strerror(result));
free(msgpref);
log_zone_error(zone_name, "DNSSEC: Could not create NSEC(3) chain: %s.\n",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
......@@ -111,9 +104,8 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_sign(zone, &zone_keys, &policy, out_ch,
refresh_at);
if (result != KNOT_EOK) {
log_zone_error("%s Error while signing (%s).\n",
msgpref, knot_strerror(result));
free(msgpref);
log_zone_error(zone_name, "DNSSEC: Error while signing: %s\n",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
......@@ -123,9 +115,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
// Check if only SOA changed
if (changeset_is_empty(out_ch) &&
!knot_zone_sign_soa_expired(zone, &zone_keys, &policy)) {
log_zone_info("%s No signing performed, zone is valid.\n",
msgpref);
free(msgpref);
log_zone_info(zone_name, "DNSSEC: No signing performed, zone is valid\n");
knot_free_zone_keys(&zone_keys);
assert(changeset_is_empty(out_ch));
return KNOT_EOK;
......@@ -138,9 +128,8 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_sign_update_soa(&soa, &rrsigs, &zone_keys, &policy,
new_serial, out_ch);
if (result != KNOT_EOK) {
log_zone_error("%s Cannot update SOA record (%s). Not signing"
"the zone!\n", msgpref, knot_strerror(result));
free(msgpref);
log_zone_error(zone_name, "DNSSEC: Not signing. Cannot update "
"SOA record: %s\n", knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
......@@ -149,8 +138,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
dbg_dnssec_detail("Zone signed: changes=%zu\n",
changeset_size(out_ch));
log_zone_info("%s Successfully signed.\n", msgpref);
free(msgpref);
log_zone_info(zone_name, "DNSSEC: Successfully signed\n");
return KNOT_EOK;
}
......@@ -187,6 +175,8 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
return KNOT_EINVAL;
}
const knot_dname_t *zone_name = zone->apex->owner;
// Keep the original serial
knot_update_serial_t soa_up = KNOT_SOA_SERIAL_KEEP;
uint32_t new_serial = zone_contents_serial(zone);
......@@ -201,31 +191,22 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
return ret;
}
char *zname = knot_dname_to_str(zone->apex->owner);
char *msgpref = sprintf_alloc("DNSSEC: Zone %s -", zname);
free(zname);
if (msgpref == NULL) {
return KNOT_ENOMEM;
}
// Sign added and removed RRSets in changeset
ret = knot_zone_sign_changeset(zone, in_ch, out_ch,
&zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to sign changeset (%s)\n", msgpref,
log_zone_error(zone_name, "DNSSEC: Failed to sign changeset: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
free(msgpref);
return ret;
}
// Create NSEC(3) chain
ret = knot_zone_create_nsec_chain(zone, out_ch, &zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to create NSEC(3) chain (%s)\n",
msgpref, knot_strerror(ret));
log_zone_error(zone_name, "DNSSEC: Failed to create NSEC(3) chain: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
free(msgpref);
return ret;
}
......@@ -233,10 +214,9 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_nsecs_in_changeset(&zone_keys, &policy,
out_ch);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to sign changeset (%s)\n",
msgpref, knot_strerror(ret));
log_zone_error(zone_name, "DNSSEC: Failed to sign changeset: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
free(msgpref);
return ret;
}
......@@ -246,15 +226,13 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_update_soa(&soa, &rrsigs, &zone_keys, &policy,
new_serial, out_ch);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to sign SOA RR (%s)\n", msgpref,
log_zone_error(zone_name, "DNSSEC: Failed to sign SOA RR: %s\n",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
free(msgpref);
return ret;
}
knot_free_zone_keys(&zone_keys);
free(msgpref);
*refresh_at = policy.refresh_before; // only new signatures are made
......
......@@ -123,14 +123,6 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
return KNOT_DNSSEC_ENOKEYDIR;
}
char *zname = knot_dname_to_str(zone_name);
char *msgpref = sprintf_alloc("DNSSEC: Zone %s -", zname);
free(zname);
if (msgpref == NULL) {
closedir(keydir);
return KNOT_ENOMEM;
}
int result = KNOT_EOK;
struct dirent entry_buf = { 0 };
......@@ -151,7 +143,6 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
if (!path) {
ERR_ALLOC_FAILED;
closedir(keydir);
free(msgpref);
return KNOT_ENOMEM;
}
......@@ -167,8 +158,8 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
free(path);
if (ret != KNOT_EOK) {
log_zone_warning("DNSSEC: Failed to load key %s: %s\n",
entry->d_name, knot_strerror(ret));
log_zone_warning(zone_name, "DNSSEC: Failed to load key '%s': %s\n",
entry->d_name, knot_strerror(ret));
knot_free_key_params(&params);
continue;
}
......@@ -198,9 +189,8 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
if (!knot_dnssec_algorithm_is_zonesign(params.algorithm,
nsec3_enabled)
) {
log_zone_notice("%s Ignoring key %d (%s): unknown "
"algorithm or non-NSEC3 algorithm when"
" NSEC3 is requested.\n", msgpref,
log_zone_notice(zone_name, "DNSSEC: Ignoring key %d (%s): "
"incompatible algorithm\n",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
......@@ -208,9 +198,9 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
}
if (knot_get_zone_key(keys, params.keytag) != NULL) {
log_zone_notice("%s Ignoring key %d (%s): duplicate "
"keytag.\n", msgpref, params.keytag,
entry->d_name);
log_zone_notice(zone_name, "DNSSEC: Ignoring key %d (%s): "
"duplicate keytag\n",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
continue;
......@@ -218,16 +208,17 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
ret = knot_dnssec_key_from_params(&params, &key->dnssec_key);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to process key %d (%s): %s\n",
msgpref, params.keytag, entry->d_name,
log_zone_error(zone_name, "DNSSEC: Failed to process "
"key %d (%s): %s\n",
params.keytag, entry->d_name,
knot_strerror(ret));
knot_free_key_params(&params);
free(key);
continue;
}
log_zone_info("%s - Loaded key %5d, file %s, %s, %s, %s\n",
msgpref, params.keytag, entry->d_name,
log_zone_info(zone_name, "DNSSEC: Loaded key %5d, file %s, %s, %s, %s\n",
params.keytag, entry->d_name,
key->is_ksk ? "KSK" : "ZSK",
key->is_active ? "active" : "inactive",
key->is_public ? "public" : "not-public");
......@@ -251,8 +242,6 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
knot_free_zone_keys(keys);
}
free(msgpref);
return result;
}
......
......@@ -346,8 +346,7 @@ static int journal_open_file(journal_t *j)
goto open_file_error;
}
if (memcmp(magic, magic_req, MAGIC_LENGTH) != 0) {
log_server_warning("Journal file '%s' version is too old, "
"it will be purged.\n", j->path);
log_warning("Journal '%s': version too old, purging", j->path);
close(j->fd);
j->fd = -1;
ret = journal_create_file(j->path, JOURNAL_NCOUNT);
......@@ -377,8 +376,7 @@ static int journal_open_file(journal_t *j)
goto open_file_error;
}
} else {
log_server_warning("Journal file '%s' CRC error, "
"it will be purged.\n", j->path);
log_warning("Journal '%s': CRC error, purging", j->path);
close(j->fd);
j->fd = -1;
ret = journal_create_file(j->path, JOURNAL_NCOUNT);
......@@ -462,14 +460,11 @@ static int journal_open_file(journal_t *j)
}
qhead_free = (jnode_flags(j, qhead_free) <= JOURNAL_FREE);
if ((j->qhead != j->qtail) && (!qtail_free || !qhead_free)) {
log_server_warning("Recovering journal '%s' metadata "
"after crash.\n",
j->path);
log_warning("Journal '%s': Recovering metadata after crash", j->path);
ret = journal_recover(j);
if (ret != KNOT_EOK) {
log_server_error("Journal file '%s' is unrecoverable, "
"metadata corrupted - %s\n",
j->path, knot_strerror(ret));
log_error("Journal '%s': Unrecoverable corruption: %s",
j->path, knot_strerror(ret));
goto open_file_error;
}
}
......
......@@ -579,8 +579,8 @@ static int process_add_nsec3param(const zone_node_t *node,
if (node == NULL || !node_rrtype_exists(node, KNOT_RRTYPE_SOA)) {
// Ignore non-apex additions
char *owner = knot_dname_to_str(rr->owner);
log_server_warning("Refusing to add NSEC3PARAM owned "
"by %s to non-apex node.\n", owner);
log_warning("Refusing to add NSEC3PARAM owned by '%s' to "
"non-apex node\n", owner);
free(owner);
return KNOT_EDENIED;
}
......@@ -590,9 +590,8 @@ static int process_add_nsec3param(const zone_node_t *node,
}
char *owner = knot_dname_to_str(rr->owner);
log_server_warning("Refusing to add NSEC3PARAM owned by %s. "
"NSEC3PARAM already present, remove it first.\n",
owner);
log_warning("Refusing to add NSEC3PARAM owned by '%s', NSEC3PARAM "
"already present, remove it first\n", owner);
free(owner);
return KNOT_EOK;
......@@ -850,7 +849,7 @@ static int check_update(const knot_rrset_t *rrset, const knot_pkt_t *query,
if (knot_rrtype_is_ddns_forbidden(rrset->type)) {
*rcode = KNOT_RCODE_REFUSED;
log_zone_warning("Refusing to update DNSSEC-related record!\n");
log_warning("Refusing to update DNSSEC-related record\n");
return KNOT_EDENIED;
}
......
......@@ -1082,8 +1082,9 @@ int zone_contents_adjust_pointers(zone_contents_t *contents)
{
int ret = zone_contents_load_nsec3param(contents);
if (ret != KNOT_EOK) {
log_zone_error("Failed to load NSEC3 params: %s\n",
knot_strerror(ret));
log_zone_error(contents->apex->owner,
"Failed to load NSEC3 parameters: %s\n",
knot_strerror(ret));
return ret;
}
......@@ -1118,8 +1119,9 @@ int zone_contents_adjust_full(zone_contents_t *zone,
int result = zone_contents_load_nsec3param(zone);
if (result != KNOT_EOK) {
log_zone_error("Failed to load NSEC3 params: %s\n",
knot_strerror(result));
log_zone_error(zone->apex->owner,
"Failed to load NSEC3 parameters: %s\n",
knot_strerror(result));
return result;
}
......@@ -1363,8 +1365,8 @@ uint32_t zone_contents_next_serial(const zone_contents_t *zone, int policy)
/* If the new serial is 'lower' or equal than the new one, warn the user.*/
if (knot_serial_compare(old_serial, new_serial) >= 0) {
log_zone_warning("New serial will be lower than "
"the current one. Old: %u new: %u.\n",
log_zone_warning(zone->apex->owner, "New serial will be lower "
"than the current one (%u -> %u)\n",
old_serial, new_serial);
}
......
......@@ -63,9 +63,8 @@ static uint32_t bootstrap_next(uint32_t timer)
/* ------------------------- zone query requesting -------------------------- */
/*! \brief Zone event logging. */
#define ZONE_QUERY_LOG(severity, zone, remote, what, msg...) \
NS_PROC_LOG(severity, LOG_ZONE, &remote->addr, zone->conf->name, \
what " of '%s' with '%s': ", msg)
#define ZONE_QUERY_LOG(priority, zone, remote, operation, msg...) \
NS_PROC_LOG(priority, &remote->addr, zone->name, operation, msg)
/*! \brief Create zone query packet. */
static knot_pkt_t *zone_query(const zone_t *zone, uint16_t pkt_type, mm_ctx_t *mm)
......@@ -163,11 +162,11 @@ fail:
}
/* @note Module specific, expects some variables set. */
#define ZONE_XFER_LOG(severity, pkt_type, msg...) \
#define ZONE_XFER_LOG(priority, pkt_type, msg...) \
if (pkt_type == KNOT_QUERY_AXFR) { \
ZONE_QUERY_LOG(severity, zone, master, "AXFR", msg); \
ZONE_QUERY_LOG(priority, zone, master, "AXFR", msg); \
} else { \
ZONE_QUERY_LOG(severity, zone, master, "IXFR", msg); \
ZONE_QUERY_LOG(priority, zone, master, "IXFR", msg); \
}
/*! \brief Execute zone transfer request. */
......@@ -212,8 +211,7 @@ static void schedule_dnssec(zone_t *zone, time_t refresh_at)
struct tm time_gm = { 0 };
localtime_r(&refresh_at, &time_gm);
strftime(time_str, sizeof(time_str), KNOT_LOG_TIME_FORMAT, &time_gm);
log_zone_info("DNSSEC: Zone %s - Next event on %s.\n",
zone->conf->name, time_str);
log_zone_info(zone->name, "DNSSEC: Next event on %s\n", time_str);
// schedule
......@@ -257,11 +255,11 @@ static int event_reload(zone_t *zone)
result = zone_load_post(contents, zone, &dnssec_refresh);
if (result != KNOT_EOK) {
if (result == KNOT_ESPACE) {
log_zone_error("Zone '%s' journal size is too small to fit the changes.\n",
zone_config->name);
log_zone_error(zone->name, "Journal size is too small "
"to fit the changes\n");
} else {
log_zone_error("Zone '%s' failed to store changes in the journal - %s\n",
zone_config->name, knot_strerror(result));
log_zone_error(zone->name, "Failed to store changes into "
"journal: %s\n", knot_strerror(result));
}
goto fail;
}
......@@ -299,7 +297,7 @@ static int event_reload(zone_t *zone)
zone_events_schedule(zone, ZONE_EVENT_FLUSH, zone_config->dbsync_timeout);
uint32_t current_serial = zone_contents_serial(zone->contents);
log_zone_info("Zone '%s' loaded (%u -> %u).\n", zone_config->name,
log_zone_info(zone->name, "Loaded, serial %u -> %u\n",
old_serial, current_serial);
return KNOT_EOK;
......@@ -437,7 +435,7 @@ static int event_expire(zone_t *zone)
zone->zonefile_serial = 0;
zone_contents_deep_free(&expired);
log_zone_info("Zone '%s' expired.\n", zone->conf->name);
log_zone_info(zone->name, "Zone expired\n");
/* Trim extra heap. */
mem_trim();
......@@ -502,24 +500,17 @@ static int event_dnssec(zone_t *zone)
assert(ch);
int ret = KNOT_ERROR;
char *zname = knot_dname_to_str(zone->name);
char *msgpref = sprintf_alloc("DNSSEC: Zone %s -", zname);
free(zname);
if (msgpref == NULL) {
ret = KNOT_ENOMEM;
goto done;
}
uint32_t refresh_at = time(NULL);
if (zone->flags & ZONE_FORCE_RESIGN) {
log_zone_info("%s Complete resign started (dropping all "
"previous signatures)...\n", msgpref);
log_zone_info(zone->name, "DNSSEC: Dropping previous "
"signatures, resigning zone\n");
zone->flags &= ~ZONE_FORCE_RESIGN;
ret = knot_dnssec_zone_sign_force(zone->contents, zone->conf,
ch, &refresh_at);
} else {
log_zone_info("%s Signing zone...\n", msgpref);
log_zone_info(zone->name, "DNSSEC: Signing zone\n");
ret = knot_dnssec_zone_sign(zone->contents, zone->conf,
ch, KNOT_SOA_SERIAL_UPDATE,
&refresh_at);
......@@ -531,8 +522,8 @@ static int event_dnssec(zone_t *zone)
if (!changesets_empty(chs)) {
ret = zone_change_apply_and_store(&chs, zone, "DNSSEC", NULL);
if (ret != KNOT_EOK) {
log_zone_error("%s Could not sign zone (%s).\n",
msgpref, knot_strerror(ret));
log_zone_error(zone->name, "DNSSEC: Could not sign zone: %s\n",
knot_strerror(ret));
goto done;
}
}
......@@ -547,7 +538,6 @@ static int event_dnssec(zone_t *zone)
done:
changesets_free(&chs, NULL);
free(msgpref);
return ret;
}
......@@ -813,8 +803,8 @@ static void event_wrap(task_t *task)
const event_info_t *info = get_event_info(type);
int result = info->callback(zone);
if (result != KNOT_EOK) {
log_zone_error("Zone '%s' event '%s' failed - %s\n", zone->conf->name,
info->name, knot_strerror(result));
log_zone_error(zone->name, "Zone %s failed: %s\n", info->name,
knot_strerror(result));
}
pthread_mutex_lock(&events->mx);
......
......@@ -57,12 +57,14 @@ int zone_load_check(zone_contents_t *contents, conf_zone_t *zone_config)
return KNOT_EOK;
}
const knot_dname_t *zone_name = contents->apex->owner;
/* Check minimum EDNS0 payload if signed. (RFC4035/sec. 3) */
if (zone_contents_is_signed(contents)) {
if (conf()->max_udp_payload < KNOT_EDNS_MIN_DNSSEC_PAYLOAD) {
log_zone_warning("EDNS payload lower than %uB for "
"DNSSEC-enabled zone '%s'.\n",
KNOT_EDNS_MIN_DNSSEC_PAYLOAD, zone_config->name);
log_zone_warning(zone_name, "EDNS payload size is "
"lower than %uB for DNSSEC zone",
KNOT_EDNS_MIN_DNSSEC_PAYLOAD);
conf()->max_udp_payload = KNOT_EDNS_MIN_DNSSEC_PAYLOAD;
}
}
......@@ -70,7 +72,7 @@ int zone_load_check(zone_contents_t *contents, conf_zone_t *zone_config)
/* Check NSEC3PARAM state if present. */
int result = zone_contents_load_nsec3param(contents);
if (result != KNOT_EOK) {
log_zone_error("NSEC3 signed zone has invalid or no "
log_zone_error(zone_name, "NSEC3 signed zone has invalid or no "
"NSEC3PARAM record.\n");
return result;
}
......@@ -111,8 +113,7 @@ int zone_load_journal(zone_contents_t *contents, conf_zone_t *zone_config)
/* Apply changesets. */
ret = apply_changesets_directly(contents, chsets);
log_zone_info("Zone '%s' serial %u -> %u: %s\n",
zone_config->name,
log_zone_info(contents->apex->owner, "Serial %u -> %u: %s\n",
serial, zone_contents_serial(contents),
knot_strerror(ret));
update_cleanup(chsets);
......@@ -169,22 +170,20 @@ int zone_load_post(zone_contents_t *contents, zone_t *zone, uint32_t *dnssec_ref
ret = zone_contents_create_diff(zone->contents, contents,
changesets_get_last(diff_change));
if (ret == KNOT_ENODIFF) {
log_zone_warning("Zone %s: Zone file changed, "
log_zone_warning(zone->name, "Zone file changed, "
"but serial didn't - won't "
"create journal entry.\n",
conf->name);
"create journal entry\n");
changesets_free(&diff_change, NULL);
} else if (ret == KNOT_ERANGE) {
log_zone_warning("Zone %s: Zone file changed, "
log_zone_warning(zone->name, "Zone file changed, "
"but serial is lower than before - "
"IXFR history will be lost.\n",
conf->name);
"IXFR history will be lost\n");
changesets_free(&diff_change, NULL);
} else if (ret != KNOT_EOK) {
log_zone_error("Zone %s: Failed to calculate "
log_zone_error(zone->name, "Failed to calculate "
"differences from the zone "
"file update: %s\n",
conf->name, knot_strerror(ret));
knot_strerror(ret));
changesets_free(&diff_change, NULL);
return ret;
}
......
......@@ -127,7 +127,7 @@ int zone_change_store(zone_t *zone, changesets_t *chset)
int ret = journal_store_changesets(chset, conf->ixfr_db, conf->ixfr_fslimit);
if (ret == KNOT_EBUSY) {
log_zone_notice("Journal for '%s' is full, flushing.\n", conf->name);
log_zone_notice(zone->name, "Zone journal is full, flushing\n");
/* Transaction rolled back, journal released, we may flush. */
ret = zone_flush_journal(zone);
......@@ -144,7 +144,7 @@ int zone_change_store(zone_t *zone, changesets_t *chset)
/*! \note @mvavrusa Moved from zones.c, this needs a common API. */
int zone_change_apply_and_store(changesets_t **chs,
zone_t *zone,
const char *msgpref,
const char *operation,
mm_ctx_t *rr_mm)
{
int ret = KNOT_EOK;
......@@ -153,7 +153,7 @@ int zone_change_apply_and_store(changesets_t **chs,
zone_contents_t *new_contents;
ret = apply_changesets(zone, *chs, &new_contents);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to apply changesets.\n", msgpref);
log_zone_error(zone->name, "%s: Failed to apply changesets\n", operation);
/* Free changesets, but not the data. */
changesets_free(chs, rr_mm);
return ret; // propagate the error above
......@@ -162,7 +162,7 @@ int zone_change_apply_and_store(changesets_t **chs,
/* Write changes to journal if all went well. */
ret = zone_change_store(zone, *chs);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to store changesets.\n", msgpref);
log_zone_error(zone->name, "%s: Failed to store changesets\n", operation);
update_rollback(*chs, &new_contents);
/* Free changesets, but not the data. */
changesets_free(chs, rr_mm);
......@@ -245,19 +245,19 @@ int zone_flush_journal(zone_t *zone)
conf_zone_t *conf = zone->conf;
int ret = zonefile_write(conf->file, contents, from);
if (ret == KNOT_EOK) {
log_zone_info("Zone '%s': zone file updated (%u -> %u).\n",
conf->name, zone->zonefile_serial, serial_to);
log_zone_info(zone->name, "Zone file updated, serial %u -> %u\n",
zone->zonefile_serial, serial_to);
} else {
log_zone_warning("Zone '%s': failed to update zone file (%s)\n",
conf->name, knot_strerror(ret));
log_zone_warning(zone->name, "Failed to update zone file: %s\n",
knot_strerror(ret));
return ret;
}
/* Update zone version. */
struct stat st;
if (stat(zone->conf->file, &st) < 0) {
log_zone_warning("Zone '%s': failed to update zone file (%s)\n",
conf->name, knot_strerror(KNOT_EACCES));
log_zone_warning(zone->name, "Failed to update zone file: %s\n",
knot_strerror(KNOT_EACCES));
return KNOT_EACCES;
}
......
......@@ -109,7 +109,7 @@ static void log_zone_load_info(const zone_t *zone, const char *zone_name,
serial = knot_soa_serial(soa);
}
log_zone_info("Zone '%s' %s (serial %u)\n", zone_name, action, serial);
log_zone_info(zone->name, "Zone %s, serial %u\n", action, serial);
}
/*!
......@@ -205,8 +205,8 @@ static knot_zonedb_t *create_zonedb(const conf_t *conf, server_t *server)
zone_t *zone = create_zone(zone_config, server, old_zone);
if (!zone) {
log_server_error("Zone '%s' cannot be created.\n",
zone_config->name);
log_zone_str_error(zone_config->name,
"Zone cannot be created\n");
conf_free_zone(zone_config);
continue;
}
......@@ -269,7 +269,7 @@ int zonedb_reload(const conf_t *conf, struct server_t *server)
be required. */
knot_zonedb_t *db_new = create_zonedb(conf, server);
if (db_new == NULL) {
log_server_error("Failed to create new zone database.\n");
log_error("Failed to create new zone database.\n");
return KNOT_ENOMEM;
}
......
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