mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
incidental cleanup
The NAME_FETCH_A and NAME_FETCH_AAAA macros were meant to be boolean, indicating whether the pointers were set or not, while the NAME_FETCH_V4 and NAME_FETCH_V6 macros were meant to return the pointer values. The latter were only used as booleans, so they've been removed in favor of the former. Also did some style cleanup and removed an unreachable code block.
This commit is contained in:
@@ -407,14 +407,10 @@ log_quota(dns_adbentry_t *entry, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
* Fetches are broken out into A and AAAA types. In some cases,
|
||||
* however, it makes more sense to test for a particular class of fetches,
|
||||
* like V4 or V6 above.
|
||||
* Note: since we have removed the support of A6 in adb, FETCH_A and FETCH_AAAA
|
||||
* are now equal to FETCH_V4 and FETCH_V6, respectively.
|
||||
*/
|
||||
#define NAME_FETCH_A(n) ((n)->fetch_a != NULL)
|
||||
#define NAME_FETCH_AAAA(n) ((n)->fetch_aaaa != NULL)
|
||||
#define NAME_FETCH_V4(n) (NAME_FETCH_A(n))
|
||||
#define NAME_FETCH_V6(n) (NAME_FETCH_AAAA(n))
|
||||
#define NAME_FETCH(n) (NAME_FETCH_V4(n) || NAME_FETCH_V6(n))
|
||||
#define NAME_FETCH(n) (NAME_FETCH_A(n) || NAME_FETCH_AAAA(n))
|
||||
|
||||
/*
|
||||
* Find options and tests to see if there are addresses on the list.
|
||||
@@ -898,18 +894,18 @@ static isc_result_t
|
||||
import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
|
||||
isc_stdtime_t now) {
|
||||
isc_result_t result;
|
||||
dns_adb_t *adb;
|
||||
dns_adbnamehook_t *nh;
|
||||
dns_adbnamehook_t *anh;
|
||||
dns_adb_t *adb = NULL;
|
||||
dns_adbnamehook_t *nh = NULL;
|
||||
dns_adbnamehook_t *anh = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
struct in_addr ina;
|
||||
struct in6_addr in6a;
|
||||
isc_sockaddr_t sockaddr;
|
||||
dns_adbentry_t *foundentry; /* NO CLEAN UP! */
|
||||
dns_adbentry_t *foundentry = NULL; /* NO CLEAN UP! */
|
||||
int addr_bucket;
|
||||
bool new_addresses_added;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_adbnamehooklist_t *hookhead;
|
||||
dns_adbnamehooklist_t *hookhead = NULL;
|
||||
|
||||
INSIST(DNS_ADBNAME_VALID(adbname));
|
||||
adb = adbname->adb;
|
||||
@@ -921,7 +917,6 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
|
||||
addr_bucket = DNS_ADB_INVALIDBUCKET;
|
||||
new_addresses_added = false;
|
||||
|
||||
nh = NULL;
|
||||
result = dns_rdataset_first(rdataset);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdata_reset(&rdata);
|
||||
@@ -978,10 +973,6 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
|
||||
result = dns_rdataset_next(rdataset);
|
||||
}
|
||||
|
||||
if (nh != NULL) {
|
||||
free_adbnamehook(adb, &nh);
|
||||
}
|
||||
|
||||
if (addr_bucket != DNS_ADB_INVALIDBUCKET) {
|
||||
UNLOCK(&adb->entrylocks[addr_bucket]);
|
||||
}
|
||||
@@ -1103,7 +1094,7 @@ check_expire_namehooks(dns_adbname_t *name, isc_stdtime_t now) {
|
||||
/*
|
||||
* Check to see if we need to remove the v4 addresses
|
||||
*/
|
||||
if (!NAME_FETCH_V4(name) && EXPIRE_OK(name->expire_v4, now)) {
|
||||
if (!NAME_FETCH_A(name) && EXPIRE_OK(name->expire_v4, now)) {
|
||||
if (NAME_HAS_V4(name)) {
|
||||
DP(DEF_LEVEL, "expiring v4 for name %p", name);
|
||||
result4 = clean_namehooks(adb, &name->v4);
|
||||
@@ -1116,7 +1107,7 @@ check_expire_namehooks(dns_adbname_t *name, isc_stdtime_t now) {
|
||||
/*
|
||||
* Check to see if we need to remove the v6 addresses
|
||||
*/
|
||||
if (!NAME_FETCH_V6(name) && EXPIRE_OK(name->expire_v6, now)) {
|
||||
if (!NAME_FETCH_AAAA(name) && EXPIRE_OK(name->expire_v6, now)) {
|
||||
if (NAME_HAS_V6(name)) {
|
||||
DP(DEF_LEVEL, "expiring v6 for name %p", name);
|
||||
result6 = clean_namehooks(adb, &name->v6);
|
||||
@@ -2867,14 +2858,17 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
||||
isc_stdtime_t now, dns_name_t *target, in_port_t port,
|
||||
unsigned int depth, isc_counter_t *qc,
|
||||
dns_adbfind_t **findp) {
|
||||
dns_adbfind_t *find;
|
||||
dns_adbname_t *adbname;
|
||||
dns_adbfind_t *find = NULL;
|
||||
dns_adbname_t *adbname = NULL;
|
||||
int bucket;
|
||||
bool want_event, start_at_zone, alias, have_address;
|
||||
bool want_event = true;
|
||||
bool start_at_zone = false;
|
||||
bool alias = false;
|
||||
bool have_address = false;
|
||||
isc_result_t result;
|
||||
unsigned int wanted_addresses;
|
||||
unsigned int wanted_fetches;
|
||||
unsigned int query_pending;
|
||||
unsigned int wanted_addresses = (options & DNS_ADBFIND_ADDRESSMASK);
|
||||
unsigned int wanted_fetches = 0;
|
||||
unsigned int query_pending = 0;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
|
||||
REQUIRE(DNS_ADB_VALID(adb));
|
||||
@@ -2890,12 +2884,6 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
||||
|
||||
result = ISC_R_UNEXPECTED;
|
||||
POST(result);
|
||||
wanted_addresses = (options & DNS_ADBFIND_ADDRESSMASK);
|
||||
wanted_fetches = 0;
|
||||
query_pending = 0;
|
||||
want_event = false;
|
||||
start_at_zone = false;
|
||||
alias = false;
|
||||
|
||||
if (now == 0) {
|
||||
isc_stdtime_get(&now);
|
||||
@@ -3043,7 +3031,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
||||
goto v6;
|
||||
}
|
||||
|
||||
if (!NAME_FETCH_V4(adbname)) {
|
||||
if (!NAME_FETCH_A(adbname)) {
|
||||
wanted_fetches |= DNS_ADBFIND_INET;
|
||||
}
|
||||
}
|
||||
@@ -3079,7 +3067,7 @@ v6:
|
||||
goto fetch;
|
||||
}
|
||||
|
||||
if (!NAME_FETCH_V6(adbname)) {
|
||||
if (!NAME_FETCH_AAAA(adbname)) {
|
||||
wanted_fetches |= DNS_ADBFIND_INET6;
|
||||
}
|
||||
}
|
||||
@@ -3140,10 +3128,10 @@ fetch:
|
||||
copy_namehook_lists(adb, find, qname, qtype, adbname, now);
|
||||
|
||||
post_copy:
|
||||
if (NAME_FETCH_V4(adbname)) {
|
||||
if (NAME_FETCH_A(adbname)) {
|
||||
query_pending |= DNS_ADBFIND_INET;
|
||||
}
|
||||
if (NAME_FETCH_V6(adbname)) {
|
||||
if (NAME_FETCH_AAAA(adbname)) {
|
||||
query_pending |= DNS_ADBFIND_INET6;
|
||||
}
|
||||
|
||||
@@ -3151,7 +3139,6 @@ post_copy:
|
||||
* Attach to the name's query list if there are queries
|
||||
* already running, and we have been asked to.
|
||||
*/
|
||||
want_event = true;
|
||||
if (!FIND_WANTEVENT(find)) {
|
||||
want_event = false;
|
||||
}
|
||||
@@ -3165,16 +3152,15 @@ post_copy:
|
||||
want_event = false;
|
||||
}
|
||||
if (want_event) {
|
||||
bool empty;
|
||||
find->adbname = adbname;
|
||||
find->name_bucket = bucket;
|
||||
bool empty = ISC_LIST_EMPTY(adbname->finds);
|
||||
empty = ISC_LIST_EMPTY(adbname->finds);
|
||||
ISC_LIST_APPEND(adbname->finds, find, plink);
|
||||
find->query_pending = (query_pending & wanted_addresses);
|
||||
find->flags &= ~DNS_ADBFIND_ADDRESSMASK;
|
||||
find->flags |= (find->query_pending & DNS_ADBFIND_ADDRESSMASK);
|
||||
DP(DEF_LEVEL,
|
||||
"createfind: attaching find %p to adbname "
|
||||
"%p %d",
|
||||
DP(DEF_LEVEL, "createfind: attaching find %p to adbname %p %d",
|
||||
find, adbname, empty);
|
||||
} else {
|
||||
/*
|
||||
@@ -3207,22 +3193,20 @@ post_copy:
|
||||
|
||||
out:
|
||||
if (find != NULL) {
|
||||
*findp = find;
|
||||
|
||||
if (want_event) {
|
||||
isc_task_t *taskp;
|
||||
isc_task_t *taskp = NULL;
|
||||
|
||||
INSIST((find->flags & DNS_ADBFIND_ADDRESSMASK) != 0);
|
||||
taskp = NULL;
|
||||
isc_task_attach(task, &taskp);
|
||||
find->event.ev_sender = taskp;
|
||||
find->event.ev_action = action;
|
||||
find->event.ev_arg = arg;
|
||||
}
|
||||
|
||||
*findp = find;
|
||||
}
|
||||
|
||||
UNLOCK(&adb->namelocks[bucket]);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -4011,8 +3995,8 @@ fetch_name(dns_adbname_t *adbname, bool start_at_zone, unsigned int depth,
|
||||
adb = adbname->adb;
|
||||
INSIST(DNS_ADB_VALID(adb));
|
||||
|
||||
INSIST((type == dns_rdatatype_a && !NAME_FETCH_V4(adbname)) ||
|
||||
(type == dns_rdatatype_aaaa && !NAME_FETCH_V6(adbname)));
|
||||
INSIST((type == dns_rdatatype_a && !NAME_FETCH_A(adbname)) ||
|
||||
(type == dns_rdatatype_aaaa && !NAME_FETCH_AAAA(adbname)));
|
||||
|
||||
adbname->fetch_err = FIND_ERR_NOTFOUND;
|
||||
|
||||
|
Reference in New Issue
Block a user