diff --git a/bin/named/server.c b/bin/named/server.c index 722e4d8de2..72cc3669e8 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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; } diff --git a/lib/ns/include/ns/listenlist.h b/lib/ns/include/ns/listenlist.h index 275be49a51..476df4c4dd 100644 --- a/lib/ns/include/ns/listenlist.h +++ b/lib/ns/include/ns/listenlist.h @@ -131,12 +131,3 @@ ns_listenlist_detach(ns_listenlist_t **listp); /*%< * Detach 'listp'. */ - -isc_result_t -ns_listenlist_default(isc_mem_t *mctx, in_port_t port, bool enabled, - const uint16_t family, ns_listenlist_t **target); -/*%< - * Create a listen-on list with default contents, matching - * all addresses with port 'port' (if 'enabled' is true), - * or no addresses (if 'enabled' is false). - */ diff --git a/lib/ns/listenlist.c b/lib/ns/listenlist.c index 1ef4a2918a..b1bde1ad82 100644 --- a/lib/ns/listenlist.c +++ b/lib/ns/listenlist.c @@ -322,45 +322,3 @@ ns_listenlist_detach(ns_listenlist_t **listp) { destroy(list); } } - -isc_result_t -ns_listenlist_default(isc_mem_t *mctx, in_port_t port, bool enabled, - const uint16_t family, ns_listenlist_t **target) { - isc_result_t result; - dns_acl_t *acl = NULL; - ns_listenelt_t *elt = NULL; - ns_listenlist_t *list = NULL; - - REQUIRE(target != NULL && *target == NULL); - if (enabled) { - result = dns_acl_any(mctx, &acl); - } else { - result = dns_acl_none(mctx, &acl); - } - if (result != ISC_R_SUCCESS) { - goto cleanup; - } - - result = ns_listenelt_create(mctx, port, acl, family, false, NULL, NULL, - ISC_NM_PROXY_NONE, &elt); - if (result != ISC_R_SUCCESS) { - goto cleanup_acl; - } - - result = ns_listenlist_create(mctx, &list); - if (result != ISC_R_SUCCESS) { - goto cleanup_listenelt; - } - - ISC_LIST_APPEND(list->elts, elt, link); - - *target = list; - return ISC_R_SUCCESS; - -cleanup_listenelt: - ns_listenelt_destroy(elt); -cleanup_acl: - dns_acl_detach(&acl); -cleanup: - return result; -} diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 25bcec7d1f..5cca2387d9 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -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; diff --git a/tests/ns/Makefile.am b/tests/ns/Makefile.am index c26bec85e6..655bdc835c 100644 --- a/tests/ns/Makefile.am +++ b/tests/ns/Makefile.am @@ -15,7 +15,6 @@ LDADD += \ $(LIBUV_LIBS) check_PROGRAMS = \ - listenlist_test \ notify_test \ plugin_test \ query_test diff --git a/tests/ns/listenlist_test.c b/tests/ns/listenlist_test.c deleted file mode 100644 index 327526dcb8..0000000000 --- a/tests/ns/listenlist_test.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#include -#include /* IWYU pragma: keep */ -#include -#include -#include -#include -#include -#include -#include - -#define UNIT_TESTING -#include - -#include -#include -#include - -#include - -#include - -#include - -/* test that ns_listenlist_default() works */ -ISC_RUN_TEST_IMPL(ns_listenlist_default) { - isc_result_t result; - in_port_t port = 5300 + isc_random8(); - ns_listenlist_t *list = NULL; - ns_listenelt_t *elt; - int count; - - UNUSED(state); - - result = ns_listenlist_default(mctx, port, false, AF_INET, &list); - assert_int_equal(result, ISC_R_SUCCESS); - assert_non_null(list); - - assert_false(ISC_LIST_EMPTY(list->elts)); - - count = 0; - elt = ISC_LIST_HEAD(list->elts); - while (elt != NULL) { - ns_listenelt_t *next = ISC_LIST_NEXT(elt, link); - dns_acl_t *acl = NULL; - - dns_acl_attach(elt->acl, &acl); - ISC_LIST_UNLINK(list->elts, elt, link); - ns_listenelt_destroy(elt); - elt = next; - - assert_true(dns_acl_isnone(acl)); - dns_acl_detach(&acl); - count++; - } - - assert_true(ISC_LIST_EMPTY(list->elts)); - assert_int_equal(count, 1); - - ns_listenlist_detach(&list); - - result = ns_listenlist_default(mctx, port, true, AF_INET, &list); - assert_int_equal(result, ISC_R_SUCCESS); - - assert_false(ISC_LIST_EMPTY(list->elts)); - - /* This time just use ns_listenlist_detach() to destroy elements */ - count = 0; - elt = ISC_LIST_HEAD(list->elts); - while (elt != NULL) { - ns_listenelt_t *next = ISC_LIST_NEXT(elt, link); - assert_true(dns_acl_isany(elt->acl)); - elt = next; - count++; - } - - assert_int_equal(count, 1); - - ns_listenlist_detach(&list); -} - -ISC_TEST_LIST_START -ISC_TEST_ENTRY(ns_listenlist_default) -ISC_TEST_LIST_END - -ISC_TEST_MAIN