From 97f26b88f62b10a9c26a91ebe8387d2e498c2d00 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Fri, 9 Feb 2001 00:23:16 +0000 Subject: [PATCH] removed more needless attaching and detaching of the blackhole ACL --- lib/dns/dispatch.c | 13 ++++--------- lib/dns/include/dns/dispatch.h | 17 +++++++++-------- lib/dns/request.c | 7 +++---- lib/dns/resolver.c | 8 ++++---- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index f0856a1bb7..2cabe53c59 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dispatch.c,v 1.91 2001/02/08 18:25:09 gson Exp $ */ +/* $Id: dispatch.c,v 1.92 2001/02/09 00:23:12 gson Exp $ */ #include @@ -1121,15 +1121,10 @@ dns_dispatchmgr_setblackhole(dns_dispatchmgr_t *mgr, dns_acl_t *blackhole) { dns_acl_attach(blackhole, &mgr->blackhole); } -isc_result_t -dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr, dns_acl_t **blackholep) { +dns_acl_t * +dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr) { REQUIRE(VALID_DISPATCHMGR(mgr)); - REQUIRE(blackholep != NULL && *blackholep == NULL); - - if (mgr->blackhole == NULL) - return (ISC_R_NOTFOUND); - dns_acl_attach(mgr->blackhole, blackholep); - return (ISC_R_SUCCESS); + return (mgr->blackhole); } static isc_result_t diff --git a/lib/dns/include/dns/dispatch.h b/lib/dns/include/dns/dispatch.h index a61c47a889..6f0705c9b3 100644 --- a/lib/dns/include/dns/dispatch.h +++ b/lib/dns/include/dns/dispatch.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dispatch.h,v 1.40 2001/02/07 05:11:58 bwelling Exp $ */ +/* $Id: dispatch.h,v 1.41 2001/02/09 00:23:16 gson Exp $ */ #ifndef DNS_DISPATCH_H #define DNS_DISPATCH_H 1 @@ -157,8 +157,8 @@ dns_dispatchmgr_destroy(dns_dispatchmgr_t **mgrp); void dns_dispatchmgr_setblackhole(dns_dispatchmgr_t *mgr, dns_acl_t *blackhole); /* - * Sets the list of addresses that will be blackholed (ignored) - * by all dispatchers created by the dispatchmgr. + * Sets the dispatcher's "blackhole list," a list of addresses that will + * be ignored by all dispatchers created by the dispatchmgr. * * Requires: * mgrp is a valid dispatchmgr @@ -166,15 +166,16 @@ dns_dispatchmgr_setblackhole(dns_dispatchmgr_t *mgr, dns_acl_t *blackhole); */ -isc_result_t -dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr, dns_acl_t **blackholep); +dns_acl_t * +dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr); /* - * Gets the list of addresses that will be blackholed (ignored) - * by all dispatchers created by the dispatchmgr. + * Gets a pointer to the dispatcher's current blackhole list, + * without incrementing its reference count. * * Requires: * mgr is a valid dispatchmgr - * blackholep != NULL && *blackholep == NULL + * Returns: + * A pointer to the current blackhole list, or NULL. */ isc_result_t diff --git a/lib/dns/request.c b/lib/dns/request.c index 387eede689..28603d2052 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: request.c,v 1.54 2001/01/27 02:28:32 bwelling Exp $ */ +/* $Id: request.c,v 1.55 2001/02/09 00:23:14 gson Exp $ */ #include @@ -467,20 +467,19 @@ new_request(isc_mem_t *mctx, dns_request_t **requestp) { static isc_boolean_t isblackholed(dns_dispatchmgr_t *dispatchmgr, isc_sockaddr_t *destaddr) { - dns_acl_t *blackhole = NULL; + dns_acl_t *blackhole; isc_netaddr_t netaddr; int match; isc_boolean_t drop = ISC_FALSE; char netaddrstr[ISC_NETADDR_FORMATSIZE]; - (void)dns_dispatchmgr_getblackhole(dispatchmgr, &blackhole); + blackhole = dns_dispatchmgr_getblackhole(dispatchmgr); if (blackhole != NULL) { isc_netaddr_fromsockaddr(&netaddr, destaddr); if (dns_acl_match(&netaddr, NULL, blackhole, NULL, &match, NULL) == ISC_R_SUCCESS && match > 0) drop = ISC_TRUE; - dns_acl_detach(&blackhole); } if (drop) { isc_netaddr_format(&netaddr, netaddrstr, sizeof(netaddrstr)); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 8b1892f5ce..ee52facdab 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.199 2001/02/09 00:13:53 gson Exp $ */ +/* $Id: resolver.c,v 1.200 2001/02/09 00:23:13 gson Exp $ */ #include @@ -850,7 +850,7 @@ resquery_send(resquery_t *query) { isc_buffer_t *buffer; isc_netaddr_t ipaddr; dns_tsigkey_t *tsigkey = NULL; - dns_acl_t *blackhole = NULL; + dns_acl_t *blackhole; dns_peer_t *peer = NULL; isc_boolean_t bogus; isc_boolean_t aborted = ISC_FALSE; @@ -1039,7 +1039,8 @@ resquery_send(resquery_t *query) { address = &query->addrinfo->sockaddr; isc_buffer_usedregion(buffer, &r); - (void)dns_dispatchmgr_getblackhole(query->dispatchmgr, &blackhole); + + blackhole = dns_dispatchmgr_getblackhole(query->dispatchmgr); if (blackhole != NULL) { int match; @@ -1047,7 +1048,6 @@ resquery_send(resquery_t *query) { NULL, &match, NULL) == ISC_R_SUCCESS && match > 0) aborted = ISC_TRUE; - dns_acl_detach(&blackhole); } peer = NULL;