Commit 216e314a authored by Daniel Salzman's avatar Daniel Salzman

flush: perform flush even when re-signed upon load keeping SOA serial

parent 4e9cf453
......@@ -683,6 +683,14 @@ int zone_update_commit(conf_t *conf, zone_update_t *update)
return KNOT_EZONESIZE;
}
/* Check if the zone was re-signed upon zone load to ensure proper flush
* even if the SOA serial wasn't incremented by re-signing. */
val = conf_zone_get(conf, C_DNSSEC_SIGNING, update->zone->name);
bool dnssec = conf_bool(&val);
if (!changeset_empty(&update->change) && dnssec) {
update->zone->zonefile.resigned = true;
}
/* Switch zone contents. */
zone_contents_t *old_contents;
old_contents = zone_switch_contents(update->zone, new_contents);
......
......@@ -103,10 +103,11 @@ static int flush_journal(conf_t *conf, zone_t *zone, bool allow_empty_zone)
return KNOT_EOK;
}
/* Check for difference against zonefile serial. */
/* Check for updated zone. */
zone_contents_t *contents = zone->contents;
uint32_t serial_to = zone_contents_serial(contents);
if (!force && zone->zonefile.exists && zone->zonefile.serial == serial_to) {
if (!force && zone->zonefile.exists && zone->zonefile.serial == serial_to &&
!zone->zonefile.resigned) {
ret = KNOT_EOK; /* No differences. */
goto flush_journal_replan;
}
......@@ -142,10 +143,11 @@ static int flush_journal(conf_t *conf, zone_t *zone, bool allow_empty_zone)
free(zonefile);
/* Update zone file serial and journal. */
/* Update zone file attributes. */
zone->zonefile.exists = true;
zone->zonefile.mtime = st.st_mtime;
zone->zonefile.serial = serial_to;
zone->zonefile.resigned = false;
/* Flush journal. */
if (zone->journal && journal_exists(zone->journal_db, zone->name)) {
......
......@@ -66,6 +66,7 @@ typedef struct zone
time_t mtime;
uint32_t serial;
bool exists;
bool resigned;
} zonefile;
/*! \brief Zone events. */
......
......@@ -9,8 +9,8 @@ t = Test()
master = t.server("knot")
slave = t.server("knot")
zone = t.zone_rnd(1, dnssec=False, records=100)
t.link(zone, master, slave)
zone = t.zone_rnd(1, dnssec=False, records=10)
t.link(zone, master, slave, ixfr=True)
master.dnssec(zone).enable = True
......@@ -32,6 +32,15 @@ master.zone_verify(zone)
# check zonefile flushed after AXFR
slave.zone_verify(zone)
# reload with re-sign (no additional serial increment)
master.ctl("zone-freeze")
master.zones[zone[0].name].zfile.update_soa()
m_mtime0 = os.stat(m_zfpath).st_mtime
t.sleep(1.5)
master.reload()
master.ctl("zone-thaw")
# DDNS test
m_mtime1 = os.stat(m_zfpath).st_mtime
s_mtime1 = os.stat(s_zfpath).st_mtime
......@@ -44,6 +53,10 @@ t.sleep(4)
m_mtime2 = os.stat(m_zfpath).st_mtime
s_mtime2 = os.stat(s_zfpath).st_mtime
# check zonefile flushed after reload with re-sign
if m_mtime1 == m_mtime0:
set_err("Not flushed after reload with re-sign")
# check zonefile flushed after DDNS
if m_mtime2 == m_mtime1:
set_err("Not flushed after DDNS")
......
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