mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 14:19:59 -04:00
moved listen list reconfiguration code from listenlist.c
to server.c
This commit is contained in:
parent
d218bede14
commit
f5f38e9930
4 changed files with 91 additions and 74 deletions
|
|
@ -30,10 +30,7 @@
|
|||
*** Imports
|
||||
***/
|
||||
|
||||
#include <dns/aclconf.h>
|
||||
#include <dns/confacl.h>
|
||||
#include <dns/confctx.h>
|
||||
#include <dns/confip.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
/***
|
||||
*** Types
|
||||
|
|
@ -62,13 +59,20 @@ struct ns_listenlist {
|
|||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenlist_t **target);
|
||||
/*
|
||||
* Create a listen list from the corresponding configuration
|
||||
* data structure.
|
||||
*/
|
||||
ns_listenelt_create(isc_mem_t *mctx, in_port_t port,
|
||||
dns_acl_t *acl, ns_listenelt_t **target);
|
||||
|
||||
void
|
||||
ns_listenelt_destroy(ns_listenelt_t *elt);
|
||||
|
||||
isc_result_t
|
||||
ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target);
|
||||
|
||||
void
|
||||
ns_listenlist_attach(ns_listenlist_t *source, ns_listenlist_t **target);
|
||||
|
||||
void
|
||||
ns_listenlist_detach(ns_listenlist_t **listp);
|
||||
|
||||
isc_result_t
|
||||
ns_listenlist_default(isc_mem_t *mctx, in_port_t port,
|
||||
|
|
@ -78,12 +82,6 @@ ns_listenlist_default(isc_mem_t *mctx, in_port_t port,
|
|||
* all addresses with port 'port'.
|
||||
*/
|
||||
|
||||
void
|
||||
ns_listenlist_attach(ns_listenlist_t *source, ns_listenlist_t **target);
|
||||
|
||||
void
|
||||
ns_listenlist_detach(ns_listenlist_t **listp);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* NS_LISTENLIST_H */
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <isc/interfaceiter.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/acl.h>
|
||||
#include <dns/dispatch.h>
|
||||
|
||||
#include <named/client.h>
|
||||
|
|
|
|||
|
|
@ -21,11 +21,13 @@
|
|||
#include <isc/mem.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
#include <dns/acl.h>
|
||||
|
||||
#include <named/listenlist.h>
|
||||
|
||||
static void destroy(ns_listenlist_t *list);
|
||||
|
||||
static isc_result_t
|
||||
isc_result_t
|
||||
ns_listenelt_create(isc_mem_t *mctx, in_port_t port,
|
||||
dns_acl_t *acl, ns_listenelt_t **target)
|
||||
{
|
||||
|
|
@ -42,35 +44,14 @@ ns_listenelt_create(isc_mem_t *mctx, in_port_t port,
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ns_listenelt_destroy(ns_listenelt_t *elt) {
|
||||
if (elt->acl != NULL)
|
||||
dns_acl_detach(&elt->acl);
|
||||
isc_mem_put(elt->mctx, elt, sizeof(*elt));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenelt_t **target)
|
||||
{
|
||||
isc_result_t result;
|
||||
ns_listenelt_t *delt = NULL;
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
result = ns_listenelt_create(mctx, celt->port, NULL, &delt);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
result = dns_acl_fromconfig(celt->iml, cctx, actx, mctx, &delt->acl);
|
||||
if (result != DNS_R_SUCCESS) {
|
||||
ns_listenelt_destroy(delt);
|
||||
return (result);
|
||||
}
|
||||
*target = delt;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
isc_result_t
|
||||
ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target) {
|
||||
ns_listenlist_t *list = NULL;
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
|
@ -84,39 +65,6 @@ ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target) {
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenlist_t **target)
|
||||
{
|
||||
dns_c_lstnon_t *ce;
|
||||
isc_result_t result;
|
||||
ns_listenlist_t *dlist = NULL;
|
||||
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
||||
result = ns_listenlist_create(mctx, &dlist);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
for (ce = ISC_LIST_HEAD(clist->elements);
|
||||
ce != NULL;
|
||||
ce = ISC_LIST_NEXT(ce, next))
|
||||
{
|
||||
ns_listenelt_t *delt = NULL;
|
||||
result = ns_listenelt_fromconfig(ce, cctx, actx, mctx, &delt);
|
||||
if (result != DNS_R_SUCCESS)
|
||||
goto cleanup;
|
||||
ISC_LIST_APPEND(dlist->elts, delt, link);
|
||||
}
|
||||
*target = dlist;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
destroy(dlist);
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy(ns_listenlist_t *list) {
|
||||
ns_listenelt_t *elt, *next;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
|
||||
#include <dns/aclconf.h>
|
||||
#include <dns/cache.h>
|
||||
#include <dns/confacl.h>
|
||||
#include <dns/confctx.h>
|
||||
#include <dns/confip.h>
|
||||
#include <dns/confparser.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/fixedname.h>
|
||||
|
|
@ -98,6 +101,14 @@ typedef struct {
|
|||
|
||||
static void fatal(char *msg, isc_result_t result);
|
||||
static void ns_server_reload(isc_task_t *task, isc_event_t *event);
|
||||
static isc_result_t
|
||||
ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenelt_t **target);
|
||||
static isc_result_t
|
||||
ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenlist_t **target);
|
||||
|
||||
/*
|
||||
* Configure 'view' according to 'cctx'.
|
||||
|
|
@ -835,3 +846,62 @@ ns_server_reloadwanted(ns_server_t *server) {
|
|||
isc_task_send(server->task, &server->reload_event);
|
||||
UNLOCK(&server->reload_event_lock);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_listenlist_fromconfig(dns_c_lstnlist_t *clist, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenlist_t **target)
|
||||
{
|
||||
dns_c_lstnon_t *ce;
|
||||
isc_result_t result;
|
||||
ns_listenlist_t *dlist = NULL;
|
||||
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
||||
result = ns_listenlist_create(mctx, &dlist);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
for (ce = ISC_LIST_HEAD(clist->elements);
|
||||
ce != NULL;
|
||||
ce = ISC_LIST_NEXT(ce, next))
|
||||
{
|
||||
ns_listenelt_t *delt = NULL;
|
||||
result = ns_listenelt_fromconfig(ce, cctx, actx, mctx, &delt);
|
||||
if (result != DNS_R_SUCCESS)
|
||||
goto cleanup;
|
||||
ISC_LIST_APPEND(dlist->elts, delt, link);
|
||||
}
|
||||
*target = dlist;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
ns_listenlist_detach(&dlist);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a listen list from the corresponding configuration
|
||||
* data structure.
|
||||
*/
|
||||
static isc_result_t
|
||||
ns_listenelt_fromconfig(dns_c_lstnon_t *celt, dns_c_ctx_t *cctx,
|
||||
dns_aclconfctx_t *actx,
|
||||
isc_mem_t *mctx, ns_listenelt_t **target)
|
||||
{
|
||||
isc_result_t result;
|
||||
ns_listenelt_t *delt = NULL;
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
result = ns_listenelt_create(mctx, celt->port, NULL, &delt);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
result = dns_acl_fromconfig(celt->iml, cctx, actx, mctx, &delt->acl);
|
||||
if (result != DNS_R_SUCCESS) {
|
||||
ns_listenelt_destroy(delt);
|
||||
return (result);
|
||||
}
|
||||
*target = delt;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue