2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Load default listen-on[-v6] values from config.c

Stop using ns_listenlist_default() to set the default listen-on
and listen-on-v6 configuration.  Instead, configure these options
using the default values in config.c.
This commit is contained in:
Petr Menšík 2021-12-06 13:42:53 +01:00 committed by Evan Hunt
parent 84f36f4dce
commit 4fa81253ea
2 changed files with 13 additions and 46 deletions

View File

@ -8511,30 +8511,16 @@ load_configuration(const char *filename, named_server_t *server,
const cfg_obj_t *clistenon = NULL;
ns_listenlist_t *listenon = NULL;
/*
* Even though listen-on is present in the default
* configuration, this way is easier.
*/
if (options != NULL) {
(void)cfg_map_get(options, "listen-on", &clistenon);
}
if (clistenon != NULL) {
result = listenlist_fromconfig(
clistenon, config, named_g_aclconfctx,
named_g_mctx, AF_INET,
server->tlsctx_server_cache, &listenon);
} else {
/*
* Not specified, use default.
*/
result = ns_listenlist_default(named_g_mctx,
listen_port, true,
AF_INET, &listenon);
}
result = named_config_get(maps, "listen-on", &clistenon);
if (result != ISC_R_SUCCESS) {
goto cleanup_v6portset;
}
result = listenlist_fromconfig(
clistenon, config, named_g_aclconfctx, named_g_mctx,
AF_INET, server->tlsctx_server_cache, &listenon);
if (result != ISC_R_SUCCESS) {
goto cleanup_v6portset;
}
if (listenon != NULL) {
ns_interfacemgr_setlistenon4(server->interfacemgr,
listenon);
@ -8549,22 +8535,13 @@ load_configuration(const char *filename, named_server_t *server,
const cfg_obj_t *clistenon = NULL;
ns_listenlist_t *listenon = NULL;
if (options != NULL) {
(void)cfg_map_get(options, "listen-on-v6", &clistenon);
}
if (clistenon != NULL) {
result = listenlist_fromconfig(
clistenon, config, named_g_aclconfctx,
named_g_mctx, AF_INET6,
server->tlsctx_server_cache, &listenon);
} else {
/*
* Not specified, use default.
*/
result = ns_listenlist_default(named_g_mctx,
listen_port, true,
AF_INET6, &listenon);
result = named_config_get(maps, "listen-on-v6", &clistenon);
if (result != ISC_R_SUCCESS) {
goto cleanup_v6portset;
}
result = listenlist_fromconfig(
clistenon, config, named_g_aclconfctx, named_g_mctx,
AF_INET6, server->tlsctx_server_cache, &listenon);
if (result != ISC_R_SUCCESS) {
goto cleanup_v6portset;
}

View File

@ -85,8 +85,6 @@ scan_interfaces(void *arg) {
int
setup_server(void **state) {
isc_result_t result;
ns_listenlist_t *listenon = NULL;
in_port_t port = 5300 + isc_random8();
setup_managers(state);
@ -103,14 +101,6 @@ setup_server(void **state) {
goto cleanup;
}
result = ns_listenlist_default(mctx, port, true, AF_INET, &listenon);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
ns_interfacemgr_setlistenon4(interfacemgr, listenon);
ns_listenlist_detach(&listenon);
isc_loop_setup(mainloop, scan_interfaces, NULL);
return 0;