/*
* Ensure that zone keys are reloaded on reconfig
*/
- if ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN) != 0) {
+ if (dns_zone_getkasp(zone) != NULL) {
dns_zone_rekey(zone, fullsign);
}
isc_result_t result;
dns_zone_t *zone = NULL;
dns_zonetype_t type;
- uint16_t keyopts;
bool fullsign = false;
char *ptr;
return DNS_R_NOTPRIMARY;
}
- keyopts = dns_zone_getkeyopts(zone);
-
/*
* "rndc loadkeys" requires a "dnssec-policy".
*/
- if ((keyopts & DNS_ZONEKEY_ALLOW) == 0) {
- result = ISC_R_NOPERM;
- } else if ((keyopts & DNS_ZONEKEY_MAINTAIN) == 0 && !fullsign) {
+ if (dns_zone_getkasp(zone) == NULL) {
result = ISC_R_NOPERM;
} else {
dns_zone_rekey(zone, fullsign);
dns_zonetype_t zonetype;
bool dynamic = false, frozen = false;
bool hasraw = false;
- bool secure, maintain, allow;
+ bool secure, maintain;
dns_db_t *db = NULL, *rawdb = NULL;
char **incfiles = NULL;
int nfiles = 0;
/* Security */
secure = dns_db_issecure(db);
- allow = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_ALLOW) != 0);
- maintain = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN) != 0);
+ maintain = (dns_zone_getkasp(zone) != NULL);
/* Master files */
file = dns_zone_getfile(mayberaw);
CHECK(putstr(text, "\nnext key event: "));
CHECK(putstr(text, kbuf));
}
- } else if (allow) {
- CHECK(putstr(text, "\nkey maintenance: on command"));
} else if (secure || hasraw) {
CHECK(putstr(text, "\nkey maintenance: none"));
}
DNS_ZONEOPT_AUTOEMPTY = 1 << 29, /*%< automatic empty zone */
DNS_ZONEOPT_CHECKSVCB = 1 << 30, /*%< check SVBC records */
DNS_ZONEOPT_ZONEVERSION = 1U << 31, /*%< enable zoneversion */
+ DNS_ZONEOPT_FULLSIGN = 1ULL << 32, /*%< fully sign zone */
DNS_ZONEOPT___MAX = UINT64_MAX, /* trick to make the ENUM 64-bit wide */
} dns_zoneopt_t;
-/*
- * Zone key maintenance options
- */
-typedef enum {
- DNS_ZONEKEY_ALLOW = 0x00000001U, /*%< fetch keys on command */
- DNS_ZONEKEY_MAINTAIN = 0x00000002U, /*%< publish/sign on schedule */
- DNS_ZONEKEY_CREATE = 0x00000004U, /*%< make keys when needed */
- DNS_ZONEKEY_FULLSIGN = 0x00000008U, /*%< roll to new keys immediately */
- DNS_ZONEKEY___MAX = UINT64_MAX, /* trick to make the ENUM 64-bit wide */
-} dns_zonekey_t;
-
/*
* Zone states
*/
*\li 'zone' to be a valid zone.
*/
-void
-dns_zone_setkeyopt(dns_zone_t *zone, unsigned int option, bool value);
-/*%<
- * Set key options on ('value' == true) or off ('value' ==
- * #false).
- *
- * Require:
- *\li 'zone' to be a valid zone.
- */
-
-unsigned int
-dns_zone_getkeyopts(dns_zone_t *zone);
-/*%<
- * Returns the current zone key options.
- *
- * Require:
- *\li 'zone' to be a valid zone.
- */
-
void
dns_zone_setminrefreshtime(dns_zone_t *zone, uint32_t val);
/*%<
uint32_t nodes;
dns_rdatatype_t privatetype;
- /*%
- * Autosigning/key-maintenance options
- */
- atomic_uint_fast64_t keyopts;
-
/*%
* True if added by "rndc addzone"
*/
#define DNS_ZONE_SETOPTION(z, o) atomic_fetch_or(&(z)->options, (o))
#define DNS_ZONE_CLROPTION(z, o) atomic_fetch_and(&(z)->options, ~(o))
-#define DNS_ZONEKEY_OPTION(z, o) \
- ((atomic_load_relaxed(&(z)->keyopts) & (o)) != 0)
-#define DNS_ZONEKEY_SETOPTION(z, o) atomic_fetch_or(&(z)->keyopts, (o))
-#define DNS_ZONEKEY_CLROPTION(z, o) atomic_fetch_and(&(z)->keyopts, ~(o))
-
/* Flags for zone_load() */
typedef enum {
DNS_ZONELOADFLAG_NOSTAT = 0x00000001U, /* Do not stat() master files */
* have been made. If we do DNSSEC maintenance on this
* zone, schedule a full sign for this zone.
*/
- if (zone->type == dns_zone_primary &&
- DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_MAINTAIN))
- {
- DNS_ZONEKEY_SETOPTION(zone, DNS_ZONEKEY_FULLSIGN);
+ if (zone->type == dns_zone_primary && zone->kasp != NULL) {
+ DNS_ZONE_SETOPTION(zone, DNS_ZONEOPT_FULLSIGN);
}
result = zone_load(zone, DNS_ZONELOADFLAG_THAW, false);
}
/*
* Schedule DNSSEC key refresh.
*/
- if (zone->type == dns_zone_primary &&
- DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_MAINTAIN))
- {
+ if (zone->type == dns_zone_primary && zone->kasp != NULL) {
zone->refreshkeytime = now;
}
dns_kasp_t *
dns_zone_getkasp(dns_zone_t *zone) {
- dns_kasp_t *kasp;
+ dns_kasp_t *kasp = NULL;
REQUIRE(DNS_ZONE_VALID(zone));
return atomic_load_relaxed(&zone->options);
}
-void
-dns_zone_setkeyopt(dns_zone_t *zone, unsigned int keyopt, bool value) {
- REQUIRE(DNS_ZONE_VALID(zone));
-
- if (value) {
- DNS_ZONEKEY_SETOPTION(zone, keyopt);
- } else {
- DNS_ZONEKEY_CLROPTION(zone, keyopt);
- }
-}
-
-unsigned int
-dns_zone_getkeyopts(dns_zone_t *zone) {
- REQUIRE(DNS_ZONE_VALID(zone));
-
- return atomic_load_relaxed(&zone->keyopts);
-}
-
void
dns_zone_setxfrsource4(dns_zone_t *zone, const isc_sockaddr_t *xfrsource) {
REQUIRE(DNS_ZONE_VALID(zone));
* True when called from "rndc sign". Indicates the zone should be
* fully signed now.
*/
- fullsign = DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_FULLSIGN);
+ fullsign = DNS_ZONE_OPTION(zone, DNS_ZONEOPT_FULLSIGN);
if (offlineksk) {
/* Lookup the correct bundle in the SKR. */
* Clear fullsign flag, if it was set, so we don't do
* another full signing next time.
*/
- DNS_ZONEKEY_CLROPTION(zone, DNS_ZONEKEY_FULLSIGN);
+ DNS_ZONE_CLROPTION(zone, DNS_ZONEOPT_FULLSIGN);
/*
* Cause the zone to add/delete NSEC3 chains for the
dnssec_log(zone, ISC_LOG_DEBUG(3),
"next key event in %u seconds", nexttime_seconds);
dnssec_log(zone, ISC_LOG_INFO, "next key event: %s", timebuf);
- }
- /*
- * If we're doing key maintenance, set the key refresh timer to
- * the next scheduled key event or to 'dnssec-loadkeys-interval'
- * seconds in the future, whichever is sooner.
- */
- else if (DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_MAINTAIN))
- {
+ } else {
+ /*
+ * If we're doing key maintenance, set the key refresh timer to
+ * the next scheduled key event or to 'dnssec-loadkeys-interval'
+ * seconds in the future, whichever is sooner.
+ */
isc_time_t timethen;
isc_stdtime_t then;
LOCK_ZONE(zone);
if (fullsign) {
- DNS_ZONEKEY_SETOPTION(zone, DNS_ZONEKEY_FULLSIGN);
+ DNS_ZONE_SETOPTION(zone, DNS_ZONEOPT_FULLSIGN);
}
now = isc_time_now();