Commit 2b65fce8 authored by Daniel Salzman's avatar Daniel Salzman

zone: replace zone_is_master with zone_is_slave

parent fc957ae4
......@@ -174,10 +174,10 @@ static int remote_zone_refresh(zone_t *zone, remote_cmdargs_t *a)
UNUSED(a);
rcu_read_lock();
bool is_master = zone_is_master(zone);
bool is_slave = zone_is_slave(zone);
rcu_read_unlock();
if (is_master) {
if (!is_slave) {
return KNOT_EINVAL;
}
......@@ -200,10 +200,10 @@ static int remote_zone_retransfer(zone_t *zone, remote_cmdargs_t *a)
UNUSED(a);
rcu_read_lock();
bool is_master = zone_is_master(zone);
bool is_slave = zone_is_slave(zone);
rcu_read_unlock();
if (is_master) {
if (!is_slave) {
return KNOT_EINVAL;
}
......@@ -356,12 +356,12 @@ static int remote_zonestatus(zone_t *zone, remote_cmdargs_t *a)
conf_val_t val = conf_zone_get(conf(), C_DNSSEC_SIGNING, zone->name);
bool dnssec_enable = conf_bool(&val);
bool is_master = zone_is_master(zone);
bool is_slave = zone_is_slave(zone);
int n = snprintf(buf, sizeof(buf),
"%s\ttype=%s | serial=%u | %s %s | %s %s\n",
zone_name,
is_master ? "master" : "slave",
is_slave ? "slave" : "master",
serial,
next_name,
when,
......
......@@ -445,7 +445,7 @@ static bool update_tsig_check(struct query_data *qdata, struct knot_request *req
static void send_update_response(const zone_t *zone, struct knot_request *req)
{
if (req->resp) {
if (zone_is_master(zone)) {
if (!zone_is_slave(zone)) {
// Sign the response with TSIG where applicable
struct query_data qdata;
init_qdata_from_request(&qdata, zone, req, NULL);
......@@ -497,7 +497,7 @@ static int init_update_responses(const zone_t *zone, list_t *updates,
assert(req->query);
knot_pkt_init_response(req->resp, req->query);
if (!zone_is_master(zone)) {
if (zone_is_slave(zone)) {
// Don't check TSIG for forwards.
continue;
}
......@@ -575,7 +575,7 @@ int updates_execute(zone_t *zone)
}
/* Process update list - forward if zone has master, or execute. */
if (!zone_is_master(zone)) {
if (zone_is_slave(zone)) {
log_zone_info(zone->name,
"DDNS, forwarding %zu updates", update_count);
forward_requests(zone, &updates);
......
......@@ -15,17 +15,14 @@
*/
#include <assert.h>
#include <urcu.h>
#include "knot/updates/apply.h"
#include "knot/zone/zone.h"
#include "knot/updates/changesets.h"
#include "knot/zone/zone.h"
#include "knot/zone/zonefile.h"
#include "libknot/libknot.h"
#include "libknot/internal/lists.h"
#include "libknot/internal/macros.h"
#include "libknot/rrtype/soa.h"
#include "libknot/rrtype/rrsig.h"
/* --------------------------- Update cleanup ------------------------------- */
......@@ -454,13 +451,9 @@ int apply_changesets(zone_t *zone, list_t *chsets, zone_contents_t **new_content
/*
* Apply the changesets.
*/
rcu_read_lock();
bool is_master = zone_is_master(zone);
rcu_read_unlock();
changeset_t *set = NULL;
WALK_LIST(set, *chsets) {
ret = apply_single(contents_copy, set, is_master);
ret = apply_single(contents_copy, set, !zone_is_slave(zone));
if (ret != KNOT_EOK) {
updates_rollback(chsets);
update_free_zone(&contents_copy);
......@@ -499,11 +492,7 @@ int apply_changeset(zone_t *zone, changeset_t *change, zone_contents_t **new_con
return ret;
}
rcu_read_lock();
bool is_master = zone_is_master(zone);
rcu_read_unlock();
ret = apply_single(contents_copy, change, is_master);
ret = apply_single(contents_copy, change, !zone_is_slave(zone));
if (ret != KNOT_EOK) {
update_rollback(change);
update_free_zone(&contents_copy);
......
......@@ -286,7 +286,7 @@ int event_reload(zone_t *zone)
}
/* Schedule notify and refresh after load. */
if (!zone_is_master(zone)) {
if (zone_is_slave(zone)) {
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
}
if (!zone_contents_is_empty(contents)) {
......@@ -319,8 +319,8 @@ int event_refresh(zone_t *zone)
{
assert(zone);
/* Ignore if master zone. */
if (zone_is_master(zone)) {
/* Ignore if not slave zone. */
if (!zone_is_slave(zone)) {
return KNOT_EOK;
}
......@@ -362,8 +362,8 @@ int event_xfer(zone_t *zone)
{
assert(zone);
/* Ignore if master zone. */
if (zone_is_master(zone)) {
/* Ignore if not slave zone. */
if (!zone_is_slave(zone)) {
return KNOT_EOK;
}
......
......@@ -35,12 +35,12 @@ static void replan_event(zone_t *zone, const zone_t *old_zone, zone_event_type_t
/*!< \brief Replans events that are dependent on the SOA record. */
static void replan_soa_events(zone_t *zone, const zone_t *old_zone)
{
if (zone_is_master(zone)) {
if (!zone_is_slave(zone)) {
// Events only valid for slaves.
return;
}
if (!zone_is_master(old_zone)) {
if (zone_is_slave(old_zone)) {
// Replan SOA events.
replan_event(zone, old_zone, ZONE_EVENT_REFRESH);
replan_event(zone, old_zone, ZONE_EVENT_EXPIRE);
......@@ -58,12 +58,12 @@ static void replan_soa_events(zone_t *zone, const zone_t *old_zone)
/*!< \brief Replans transfer event. */
static void replan_xfer(zone_t *zone, const zone_t *old_zone)
{
if (zone_is_master(zone)) {
if (!zone_is_slave(zone)) {
// Only valid for slaves.
return;
}
if (!zone_is_master(old_zone)) {
if (zone_is_slave(old_zone)) {
// Replan the transfer from old zone.
replan_event(zone, old_zone, ZONE_EVENT_XFER);
} else if (zone_contents_is_empty(zone->contents)) {
......
......@@ -178,10 +178,14 @@ zone_contents_t *zone_switch_contents(zone_t *zone, zone_contents_t *new_content
return old_contents;
}
bool zone_is_master(const zone_t *zone)
bool zone_is_slave(const zone_t *zone)
{
if (zone == NULL) {
return false;
}
conf_val_t val = conf_zone_get(conf(), C_MASTER, zone->name);
return conf_val_count(&val) > 0 ? false : true;
return conf_val_count(&val) > 0 ? true : false;
}
conf_remote_t zone_master(const zone_t *zone)
......@@ -227,7 +231,7 @@ int zone_flush_journal(zone_t *zone)
/* Fetch zone source (where it came from). */
const struct sockaddr_storage *from = NULL;
conf_remote_t master;
if (!zone_is_master(zone)) {
if (zone_is_slave(zone)) {
master = zone_master(zone);
from = &master.addr;
}
......
......@@ -112,8 +112,8 @@ int zone_change_store(zone_t *zone, changeset_t *change);
zone_contents_t *zone_switch_contents(zone_t *zone,
zone_contents_t *new_contents);
/*! \brief Check if the zone has some masters. */
bool zone_is_master(const zone_t *zone);
/*! \brief Checks if the zone is slave. */
bool zone_is_slave(const zone_t *zone);
/*! \brief Return the current zone master. */
conf_remote_t zone_master(const zone_t *zone);
......
......@@ -176,7 +176,7 @@ static void reuse_events(zone_t *zone, const time_t *timers)
// Timer unset.
continue;
}
if (slave_event(event) && zone_is_master(zone)) {
if (slave_event(event) && !zone_is_slave(zone)) {
// Slave-only event.
continue;
}
......
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