Unify parental-agents, primaries to remote-servers
Having zone statements that are also top blocks is confusing, and if
we want to add more in the future (which I suspect will be for
generalized notifications, multi-signer), we need to duplicate a lot
of code.
Remove top blocks 'parental-agents' and 'primaries' and just have one
top block 'remote-servers' that you can refer to with zone statements.
(cherry picked from commit b121f02eac)
This commit is contained in:
@@ -2210,10 +2210,11 @@ check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
|
||||
}
|
||||
|
||||
/*
|
||||
* Check primaries lists for duplicates.
|
||||
* Check remote-server lists for duplicates.
|
||||
*/
|
||||
static isc_result_t
|
||||
check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx, isc_mem_t *mctx) {
|
||||
check_remoteserverlists(const cfg_obj_t *cctx, isc_log_t *logctx,
|
||||
isc_mem_t *mctx) {
|
||||
isc_result_t result, tresult;
|
||||
isc_symtab_t *symtab = NULL;
|
||||
|
||||
@@ -2221,37 +2222,11 @@ check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx, isc_mem_t *mctx) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
tresult = check_remoteserverlist(cctx, "primaries", logctx, symtab,
|
||||
tresult = check_remoteserverlist(cctx, "remote-servers", logctx, symtab,
|
||||
mctx);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
}
|
||||
tresult = check_remoteserverlist(cctx, "masters", logctx, symtab, mctx);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
}
|
||||
isc_symtab_destroy(&symtab);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check parental-agents lists for duplicates.
|
||||
*/
|
||||
static isc_result_t
|
||||
check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
|
||||
isc_mem_t *mctx) {
|
||||
isc_result_t result, tresult;
|
||||
isc_symtab_t *symtab = NULL;
|
||||
|
||||
result = isc_symtab_create(mctx, 100, freekey, mctx, false, &symtab);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
tresult = check_remoteserverlist(cctx, "parental-agents", logctx,
|
||||
symtab, mctx);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
}
|
||||
isc_symtab_destroy(&symtab);
|
||||
return result;
|
||||
}
|
||||
@@ -2525,8 +2500,8 @@ check_tls_definitions(const cfg_obj_t *config, isc_log_t *logctx,
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
get_remotes(const cfg_obj_t *cctx, const char *list, const char *name,
|
||||
const cfg_obj_t **ret) {
|
||||
get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx,
|
||||
const cfg_obj_t **ret) {
|
||||
isc_result_t result;
|
||||
const cfg_obj_t *obj = NULL;
|
||||
const cfg_listelt_t *elt = NULL;
|
||||
@@ -2555,25 +2530,8 @@ get_remotes(const cfg_obj_t *cctx, const char *list, const char *name,
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx,
|
||||
const cfg_obj_t **ret) {
|
||||
isc_result_t result = ISC_R_NOTFOUND;
|
||||
|
||||
if (strcmp(list, "primaries") == 0) {
|
||||
result = get_remotes(cctx, "primaries", name, ret);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
result = get_remotes(cctx, "masters", name, ret);
|
||||
}
|
||||
} else if (strcmp(list, "parental-agents") == 0) {
|
||||
result = get_remotes(cctx, "parental-agents", name, ret);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
validate_remotes(const char *list, const cfg_obj_t *obj,
|
||||
const cfg_obj_t *config, uint32_t *countp, isc_log_t *logctx,
|
||||
isc_mem_t *mctx) {
|
||||
validate_remotes(const cfg_obj_t *obj, const cfg_obj_t *config,
|
||||
uint32_t *countp, isc_log_t *logctx, isc_mem_t *mctx) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t tresult;
|
||||
uint32_t count = 0;
|
||||
@@ -2679,13 +2637,14 @@ resume:
|
||||
if (tresult == ISC_R_EXISTS) {
|
||||
continue;
|
||||
}
|
||||
tresult = get_remoteservers_def(list, listname, config, &obj);
|
||||
tresult = get_remoteservers_def("remote-servers", listname,
|
||||
config, &obj);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
}
|
||||
cfg_obj_log(addr, logctx, ISC_LOG_ERROR,
|
||||
"unable to find %s list '%s'", list,
|
||||
"unable to find remote-servers list '%s'",
|
||||
listname);
|
||||
continue;
|
||||
}
|
||||
@@ -3582,8 +3541,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
||||
}
|
||||
if (tresult == ISC_R_SUCCESS && donotify) {
|
||||
uint32_t count;
|
||||
tresult = validate_remotes("primaries", obj, config,
|
||||
&count, logctx, mctx);
|
||||
tresult = validate_remotes(obj, config, &count, logctx,
|
||||
mctx);
|
||||
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
|
||||
{
|
||||
result = tresult;
|
||||
@@ -3625,8 +3584,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
||||
result = ISC_R_FAILURE;
|
||||
} else {
|
||||
uint32_t count;
|
||||
tresult = validate_remotes("primaries", obj, config,
|
||||
&count, logctx, mctx);
|
||||
tresult = validate_remotes(obj, config, &count, logctx,
|
||||
mctx);
|
||||
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
|
||||
{
|
||||
result = tresult;
|
||||
@@ -3678,8 +3637,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
||||
(void)cfg_map_get(zoptions, "parental-agents", &obj);
|
||||
if (obj != NULL) {
|
||||
uint32_t count;
|
||||
tresult = validate_remotes("parental-agents", obj,
|
||||
config, &count, logctx,
|
||||
tresult = validate_remotes(obj, config, &count, logctx,
|
||||
mctx);
|
||||
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
|
||||
{
|
||||
@@ -6181,11 +6139,7 @@ isccfg_check_namedconf(const cfg_obj_t *config, unsigned int flags,
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
if (check_primarylists(config, logctx, mctx) != ISC_R_SUCCESS) {
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
if (check_parentalagentlists(config, logctx, mctx) != ISC_R_SUCCESS) {
|
||||
if (check_remoteserverlists(config, logctx, mctx) != ISC_R_SUCCESS) {
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,8 +1260,7 @@ static cfg_clausedef_t namedconf_clauses[] = {
|
||||
{ "masters", &cfg_type_remoteservers,
|
||||
CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NODOC },
|
||||
{ "options", &cfg_type_options, 0 },
|
||||
{ "parental-agents", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "primaries", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "remote-servers", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI },
|
||||
#if defined(HAVE_LIBXML2) || defined(HAVE_JSON_C)
|
||||
{ "statistics-channels", &cfg_type_statschannels,
|
||||
CFG_CLAUSEFLAG_MULTI },
|
||||
|
||||
Reference in New Issue
Block a user