mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Implement catalog zones options new syntax based on custom properties
According to DNS catalog zones draft version 5 document, catalog zone custom properties must be placed under the "ext" label. Make necessary changes to support the new custom properties syntax in catalog zones with version "2" of the schema. Change the default catalog zones schema version from "1" to "2" in ARM to prepare for the new features and changes which come starting from this commit in order to support the latest DNS catalog zones draft document. Make some restructuring in ARM and rename the term catalog zone "option" to "custom property" to better reflect the terms used in the draft. Change the version of 'catalog1.zone.' catalog zone in the "catz" system test to "2", and leave the version of 'catalog2.zone.' catalog zone at version "1" to test both versions. Add tests to check that the new syntax works only with the new schema version, and that the old syntax works only with the legacy schema version catalog zones.
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
#define DNS_CATZ_ZONES_VALID(catzs) ISC_MAGIC_VALID(catzs, DNS_CATZ_ZONES_MAGIC)
|
||||
#define DNS_CATZ_ENTRY_VALID(entry) ISC_MAGIC_VALID(entry, DNS_CATZ_ENTRY_MAGIC)
|
||||
|
||||
#define DNS_CATZ_VERSION_UNDEFINED ((uint32_t)(-1))
|
||||
|
||||
/*%
|
||||
* Single member zone in a catalog
|
||||
*/
|
||||
@@ -646,7 +648,7 @@ dns_catz_new_zone(dns_catz_zones_t *catzs, dns_catz_zone_t **zonep,
|
||||
dns_catz_options_init(&new_zone->zoneoptions);
|
||||
new_zone->active = true;
|
||||
new_zone->db_registered = false;
|
||||
new_zone->version = (uint32_t)(-1);
|
||||
new_zone->version = DNS_CATZ_VERSION_UNDEFINED;
|
||||
isc_refcount_init(&new_zone->refs, 1);
|
||||
new_zone->magic = DNS_CATZ_ZONE_MAGIC;
|
||||
|
||||
@@ -824,10 +826,12 @@ dns_catz_catzs_detach(dns_catz_zones_t **catzsp) {
|
||||
typedef enum {
|
||||
CATZ_OPT_NONE,
|
||||
CATZ_OPT_ZONES,
|
||||
CATZ_OPT_VERSION,
|
||||
CATZ_OPT_CUSTOM_START, /* CATZ custom properties must go below this */
|
||||
CATZ_OPT_EXT,
|
||||
CATZ_OPT_MASTERS,
|
||||
CATZ_OPT_ALLOW_QUERY,
|
||||
CATZ_OPT_ALLOW_TRANSFER,
|
||||
CATZ_OPT_VERSION,
|
||||
} catz_opt_t;
|
||||
|
||||
static bool
|
||||
@@ -844,7 +848,9 @@ catz_opt_cmp(const dns_label_t *option, const char *opt) {
|
||||
|
||||
static catz_opt_t
|
||||
catz_get_option(const dns_label_t *option) {
|
||||
if (catz_opt_cmp(option, "zones")) {
|
||||
if (catz_opt_cmp(option, "ext")) {
|
||||
return (CATZ_OPT_EXT);
|
||||
} else if (catz_opt_cmp(option, "zones")) {
|
||||
return (CATZ_OPT_ZONES);
|
||||
} else if (catz_opt_cmp(option, "masters") ||
|
||||
catz_opt_cmp(option, "primaries")) {
|
||||
@@ -1279,18 +1285,32 @@ catz_process_zones_suboption(dns_catz_zone_t *zone, dns_rdataset_t *value,
|
||||
dns_label_t option;
|
||||
dns_name_t prefix;
|
||||
catz_opt_t opt;
|
||||
unsigned int suffix_labels = 1;
|
||||
|
||||
REQUIRE(DNS_CATZ_ZONE_VALID(zone));
|
||||
REQUIRE(mhash != NULL);
|
||||
REQUIRE(DNS_RDATASET_VALID(value));
|
||||
REQUIRE(ISC_MAGIC_VALID(name, DNS_NAME_MAGIC));
|
||||
|
||||
if (name->labels == 0) {
|
||||
if (name->labels < 1) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
dns_name_getlabel(name, name->labels - 1, &option);
|
||||
opt = catz_get_option(&option);
|
||||
|
||||
/*
|
||||
* The custom properties in version 2 schema must be placed under the
|
||||
* "ext" label.
|
||||
*/
|
||||
if (zone->version >= 2 && opt >= CATZ_OPT_CUSTOM_START) {
|
||||
if (opt != CATZ_OPT_EXT || name->labels < 2) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
suffix_labels++;
|
||||
dns_name_getlabel(name, name->labels - 2, &option);
|
||||
opt = catz_get_option(&option);
|
||||
}
|
||||
|
||||
/*
|
||||
* We're adding this entry now, in case the option is invalid we'll get
|
||||
* rid of it in verification phase.
|
||||
@@ -1308,7 +1328,7 @@ catz_process_zones_suboption(dns_catz_zone_t *zone, dns_rdataset_t *value,
|
||||
}
|
||||
|
||||
dns_name_init(&prefix, NULL);
|
||||
dns_name_split(name, 1, &prefix, NULL);
|
||||
dns_name_split(name, suffix_labels, &prefix, NULL);
|
||||
switch (opt) {
|
||||
case CATZ_OPT_MASTERS:
|
||||
return (catz_process_primaries(zone, &entry->opts.masters,
|
||||
@@ -1358,15 +1378,34 @@ catz_process_value(dns_catz_zone_t *zone, dns_name_t *name,
|
||||
dns_label_t option;
|
||||
dns_name_t prefix;
|
||||
catz_opt_t opt;
|
||||
unsigned int suffix_labels = 1;
|
||||
|
||||
REQUIRE(DNS_CATZ_ZONE_VALID(zone));
|
||||
REQUIRE(ISC_MAGIC_VALID(name, DNS_NAME_MAGIC));
|
||||
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
||||
|
||||
if (name->labels < 1) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
dns_name_getlabel(name, name->labels - 1, &option);
|
||||
opt = catz_get_option(&option);
|
||||
|
||||
/*
|
||||
* The custom properties in version 2 schema must be placed under the
|
||||
* "ext" label.
|
||||
*/
|
||||
if (zone->version >= 2 && opt >= CATZ_OPT_CUSTOM_START) {
|
||||
if (opt != CATZ_OPT_EXT || name->labels < 2) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
suffix_labels++;
|
||||
dns_name_getlabel(name, name->labels - 2, &option);
|
||||
opt = catz_get_option(&option);
|
||||
}
|
||||
|
||||
dns_name_init(&prefix, NULL);
|
||||
dns_name_split(name, 1, &prefix, NULL);
|
||||
dns_name_split(name, suffix_labels, &prefix, NULL);
|
||||
|
||||
switch (opt) {
|
||||
case CATZ_OPT_ZONES:
|
||||
return (catz_process_zones(zone, rdataset, &prefix));
|
||||
|
Reference in New Issue
Block a user