From 990dd9dbff5826af3549ca60df6f15b74a345d9a Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 5 Mar 2021 14:28:33 -0800 Subject: [PATCH] fix automatic journal upgrade on windows - use a value less than 2^32 for DNS_ZONEFLG_FIXJOURNAL; a larger value could cause problems in some build environments. the zone flag DNS_ZONEFLG_DIFFONRELOAD, which was no longer in use, has now been deleted and its value reused for _FIXJOURNAL. --- lib/dns/include/dns/journal.h | 22 +++++++++++++++++++--- lib/dns/zone.c | 31 +++++++++++++++++-------------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/lib/dns/include/dns/journal.h b/lib/dns/include/dns/journal.h index e115bbc226..be6d72ba43 100644 --- a/lib/dns/include/dns/journal.h +++ b/lib/dns/include/dns/journal.h @@ -302,8 +302,24 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial, uint32_t flags, uint32_t target_size); /*%< * Attempt to compact the journal if it is greater that 'target_size'. - * Changes from 'serial' onwards will be preserved. If the journal - * exists and is non-empty 'serial' must exist in the journal. + * Changes from 'serial' onwards will be preserved. Changes prior than + * that may be dropped in order to get the journal below `target_size`. + * + * If 'flags' includes DNS_JOURNAL_COMPACTALL, the entire journal is copied. + * In this case, `serial` is ignored. This flag is used when upgrading or + * downgrading the format version of the journal. If 'flags' also includes + * DNS_JOURNAL_VERSION1, then the journal is copied out in the original + * format used prior to BIND 9.16.12; otherwise it is copied in the + * current format. + * + * If _COMPACTALL is not in use, and the journal file exists and is + * non-empty, then 'serial' must exist in the journal. + * + * Returns: + *\li ISC_R_SUCCESS + *\li ISC_R_RANGE serial is outside the range existing in the journal + * + * Other errors may be returned from file operations. */ bool @@ -314,7 +330,7 @@ dns_journal_set_sourceserial(dns_journal_t *j, uint32_t sourceserial); * Get and set source serial. * * Returns: - * true if sourceserial has previously been set. + * true if sourceserial has previously been set. */ ISC_LANG_ENDDECLS diff --git a/lib/dns/zone.c b/lib/dns/zone.c index ae21050106..e172f064b9 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -474,17 +474,18 @@ typedef enum { * up-to-date */ DNS_ZONEFLG_NEEDNOTIFY = 0x00000400U, /*%< need to send out notify * messages */ - DNS_ZONEFLG_DIFFONRELOAD = 0x00000800U, /*%< generate a journal diff on - * reload */ - DNS_ZONEFLG_NOMASTERS = 0x00001000U, /*%< an attempt to refresh a - * zone with no primaries - * occurred */ - DNS_ZONEFLG_LOADING = 0x00002000U, /*%< load from disk in progress*/ - DNS_ZONEFLG_HAVETIMERS = 0x00004000U, /*%< timer values have been set - * from SOA (if not set, we - * are still using - * default timer values) */ - DNS_ZONEFLG_FORCEXFER = 0x00008000U, /*%< Force a zone xfer */ + DNS_ZONEFLG_FIXJOURNAL = 0x00000800U, /*%< journal file had + * recoverable error, + * needs rewriting */ + DNS_ZONEFLG_NOMASTERS = 0x00001000U, /*%< an attempt to refresh a + * zone with no primaries + * occurred */ + DNS_ZONEFLG_LOADING = 0x00002000U, /*%< load from disk in progress*/ + DNS_ZONEFLG_HAVETIMERS = 0x00004000U, /*%< timer values have been set + * from SOA (if not set, we + * are still using + * default timer values) */ + DNS_ZONEFLG_FORCEXFER = 0x00008000U, /*%< Force a zone xfer */ DNS_ZONEFLG_NOREFRESH = 0x00010000U, DNS_ZONEFLG_DIALNOTIFY = 0x00020000U, DNS_ZONEFLG_DIALREFRESH = 0x00040000U, @@ -504,9 +505,11 @@ typedef enum { * notify due to the zone * just being loaded for * the first time. */ - DNS_ZONEFLG_FIXJOURNAL = 0x100000000U, /*%< journal file had - * recoverable error, - * needs rewriting */ + /* + * DO NOT add any new zone flags here until all platforms + * support 64-bit enum values. Currently they fail on + * Windows. + */ DNS_ZONEFLG___MAX = UINT64_MAX, /* trick to make the ENUM 64-bit wide */ } dns_zoneflg_t;