adb.c revision dd95acdbce0e2a2775391709cdfca0a9eda7e8f7
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 1999-2003 Internet Software Consortium.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Permission to use, copy, modify, and distribute this software for any
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PERFORMANCE OF THIS SOFTWARE.
e61793f0865117ad87a19d6e245bea8f3b712d1bDanny Mayer/* $Id: adb.c,v 1.218 2004/11/10 22:33:18 marka Exp $ */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Implementation notes
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff * --------------------
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * In finds, if task == NULL, no events will be generated, and no events
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * have been sent. If task != NULL but taskaction == NULL, an event has been
90c845947a6987a95d4facaed61406362fbb58dfBrian Wellington * posted but not yet freed. If neither are NULL, no event was posted.
363cb30a83e8e57bc8874e621910f0e23dd84909Mark Andrews * After we have cleaned all buckets, dump the database contents.
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#include <isc/string.h> /* Required for HP/UX (and others?) */
001d1ceec69e181f62367f4d344fb386135d91b1Andreas Gustafsson#define DNS_ADB_MAGIC ISC_MAGIC('D', 'a', 'd', 'b')
71811653336a000f6c61d26d4b2a0c0d2cec9c25Danny Mayer#define DNS_ADB_VALID(x) ISC_MAGIC_VALID(x, DNS_ADB_MAGIC)
71811653336a000f6c61d26d4b2a0c0d2cec9c25Danny Mayer#define DNS_ADBNAME_MAGIC ISC_MAGIC('a', 'd', 'b', 'N')
71811653336a000f6c61d26d4b2a0c0d2cec9c25Danny Mayer#define DNS_ADBNAME_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBNAME_MAGIC)
e61793f0865117ad87a19d6e245bea8f3b712d1bDanny Mayer#define DNS_ADBNAMEHOOK_MAGIC ISC_MAGIC('a', 'd', 'N', 'H')
e61793f0865117ad87a19d6e245bea8f3b712d1bDanny Mayer#define DNS_ADBNAMEHOOK_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBNAMEHOOK_MAGIC)
412e5c62115e881cce79921e2467c6c0990a0a8aBrian Wellington#define DNS_ADBZONEINFO_MAGIC ISC_MAGIC('a', 'd', 'b', 'Z')
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBZONEINFO_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBZONEINFO_MAGIC)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBENTRY_MAGIC ISC_MAGIC('a', 'd', 'b', 'E')
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBENTRY_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBENTRY_MAGIC)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBFETCH_MAGIC ISC_MAGIC('a', 'd', 'F', '4')
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBFETCH_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBFETCH_MAGIC)
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBFETCH6_MAGIC ISC_MAGIC('a', 'd', 'F', '6')
03a0fca86dd9db6a40743107ec9dea7c33e46a7aDavid Lawrence#define DNS_ADBFETCH6_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBFETCH6_MAGIC)
01933e930208da3291de3722cb0d0787636b1e4fMichael Graff * The number of buckets needs to be a prime (for good hashing).
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * XXXRTH How many buckets do we need?
efe2f579ba6fbec4229129015780f2d925085b04Michael Graff#define NBUCKETS 1009 /* how many buckets for names/addrs */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * For type 3 negative cache entries, we will remember that the address is
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * broken for this long. XXXMLG This is also used for actual addresses, too.
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * The intent is to keep us from constantly asking about A/AAAA records
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * if the zone has extremely low TTLs.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff#define ADB_CACHE_MAXIMUM 86400 /* seconds (86400 = 24 hours) */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Wake up every CLEAN_SECONDS and clean CLEAN_BUCKETS buckets, so that all
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * buckets are cleaned in CLEAN_PERIOD seconds.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff#define CLEAN_BUCKETS ((NBUCKETS * CLEAN_SECONDS) / CLEAN_PERIOD)
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff#define FREE_ITEMS 64 /* free count for memory pools */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff#define FILL_COUNT 16 /* fill count for memory pools */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff#define DNS_ADB_INVALIDBUCKET (-1) /* invalid bucket address */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff#define DNS_ADB_MINADBSIZE (1024*1024) /* 1 Megabyte */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Grafftypedef ISC_LIST(dns_adbname_t) dns_adbnamelist_t;
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Grafftypedef struct dns_adbnamehook dns_adbnamehook_t;
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Grafftypedef ISC_LIST(dns_adbnamehook_t) dns_adbnamehooklist_t;
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Grafftypedef struct dns_adbzoneinfo dns_adbzoneinfo_t;
1d1d2fa57a954333c32ca3104b812b4e2389196fBrian Wellingtontypedef ISC_LIST(dns_adbentry_t) dns_adbentrylist_t;
d736db6dc53e615e3f2d66d1ddbe28473694d107Michael Graff unsigned int magic;
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff isc_mutex_t reflock; /* Covers irefcnt, erefcnt */
c1cfd8ef05f47f2ccb5db80639e9501c9f16864cMichael Graff unsigned int irefcnt;
c1cfd8ef05f47f2ccb5db80639e9501c9f16864cMichael Graff unsigned int erefcnt;
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * Bucketized locks and lists for names.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * XXXRTH Have a per-bucket structure that contains all of these?
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Bucketized locks for entries.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * XXXRTH Have a per-bucket structure that contains all of these?
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff isc_boolean_t entry_sd[NBUCKETS]; /* shutting down */
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff * XXXMLG Document these structures.
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff unsigned int magic;
64bed6c54393c2d213db83e9b171fb7c318cfc8eMichael Graff unsigned int flags;
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence unsigned int chains;
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * dns_adbnamehook_t
5b34d8267e8228b4615b9eae4e32d9ad1f308179Andreas Gustafsson * This is a small widget that dangles off a dns_adbname_t. It contains a
5b34d8267e8228b4615b9eae4e32d9ad1f308179Andreas Gustafsson * pointer to the address information about this host, and a link to the next
5b34d8267e8228b4615b9eae4e32d9ad1f308179Andreas Gustafsson * namehook that will contain the next address this host has.
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * dns_adbzoneinfo_t
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * This is a small widget that holds zone-specific information about an
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * address. Currently limited to lameness, but could just as easily be
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * extended to other types of information about zones.
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * An address entry. It holds quite a bit of information about addresses,
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff * including edns state (in "flags"), rtt, and of course the address of
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff unsigned int magic;
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff unsigned int refcnt;
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff unsigned int flags;
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff unsigned int srtt;
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff * A nonzero 'expires' field indicates that the entry should
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff * persist until that time. This allows entries found
8cd870e3f5e3db9808a4a0d6f98db3d1a5348e40Michael Graff * using dns_adb_findaddrinfo() to persist for a limited time
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff * even though they are not necessarily associated with a
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson * Internal functions (and prototypes).
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline dns_adbname_t *new_adbname(dns_adb_t *, dns_name_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void free_adbname(dns_adb_t *, dns_adbname_t **);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline dns_adbnamehook_t *new_adbnamehook(dns_adb_t *,
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void free_adbnamehook(dns_adb_t *, dns_adbnamehook_t **);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline dns_adbzoneinfo_t *new_adbzoneinfo(dns_adb_t *, dns_name_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void free_adbzoneinfo(dns_adb_t *, dns_adbzoneinfo_t **);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline dns_adbentry_t *new_adbentry(dns_adb_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline void free_adbentry(dns_adb_t *, dns_adbentry_t **);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline dns_adbfind_t *new_adbfind(dns_adb_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline isc_boolean_t free_adbfind(dns_adb_t *, dns_adbfind_t **);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline dns_adbaddrinfo_t *new_adbaddrinfo(dns_adb_t *, dns_adbentry_t *,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline dns_adbfetch_t *new_adbfetch(dns_adb_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline void free_adbfetch(dns_adb_t *, dns_adbfetch_t **);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline dns_adbname_t *find_name_and_lock(dns_adb_t *, dns_name_t *,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson unsigned int, int *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline dns_adbentry_t *find_entry_and_lock(dns_adb_t *,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void dump_adb(dns_adb_t *, FILE *, isc_boolean_t debug, isc_stdtime_t);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void print_dns_name(FILE *, dns_name_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void print_namehook_list(FILE *, const char *legend,
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic void print_find_list(FILE *, dns_adbname_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void print_fetch_list(FILE *, dns_adbname_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline isc_boolean_t dec_adb_irefcnt(dns_adb_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void inc_adb_irefcnt(dns_adb_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void inc_adb_erefcnt(dns_adb_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void inc_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline isc_boolean_t dec_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic isc_boolean_t clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void clean_target(dns_adb_t *, dns_name_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void clean_finds_at_name(dns_adbname_t *, isc_eventtype_t,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson unsigned int);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic isc_boolean_t check_expire_namehooks(dns_adbname_t *, isc_stdtime_t,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic void cancel_fetches_at_name(dns_adbname_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic isc_result_t dbfind_name(dns_adbname_t *, isc_stdtime_t,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic isc_result_t fetch_name(dns_adbname_t *, isc_boolean_t,
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline void check_exit(dns_adb_t *);
5733d25b06b46067b3751d10436d82aef09cd705Brian Wellingtonstatic void timer_cleanup(isc_task_t *, isc_event_t *);
5733d25b06b46067b3751d10436d82aef09cd705Brian Wellingtonstatic isc_boolean_t shutdown_names(dns_adb_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic isc_boolean_t shutdown_entries(dns_adb_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline void link_name(dns_adb_t *, int, dns_adbname_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline isc_boolean_t unlink_name(dns_adb_t *, dns_adbname_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline void link_entry(dns_adb_t *, int, dns_adbentry_t *);
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafssonstatic inline isc_boolean_t unlink_entry(dns_adb_t *, dns_adbentry_t *);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic isc_boolean_t kill_name(dns_adbname_t **, isc_eventtype_t);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic void water(void *, int);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellingtonstatic void dump_entry(FILE *, dns_adbentry_t *, isc_boolean_t, isc_stdtime_t);
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington * MUST NOT overlap DNS_ADBFIND_* flags!
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington#define FIND_EVENTSENT(h) (((h)->flags & FIND_EVENT_SENT) != 0)
8f80322fb58bac39c84bb76cb2bc82406bd6a9ecBrian Wellington#define FIND_EVENTFREED(h) (((h)->flags & FIND_EVENT_FREED) != 0)
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define NAME_STARTATZONE DNS_ADBFIND_STARTATZONE
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define NAME_DEAD(n) (((n)->flags & NAME_IS_DEAD) != 0)
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define NAME_NEEDSPOKE(n) (((n)->flags & NAME_NEEDS_POKE) != 0)
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define NAME_GLUEOK(n) (((n)->flags & NAME_GLUE_OK) != 0)
01933e930208da3291de3722cb0d0787636b1e4fMichael Graff#define NAME_HINTOK(n) (((n)->flags & NAME_HINT_OK) != 0)
1a70537f01305cb84d402c84b1ba7cc89b97a5dcMichael Graff * To the name, address classes are all that really exist. If it has a
1a70537f01305cb84d402c84b1ba7cc89b97a5dcMichael Graff * V6 address it doesn't care if it came from a AAAA query.
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define NAME_HAS_V4(n) (!ISC_LIST_EMPTY((n)->v4))
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define NAME_HAS_V6(n) (!ISC_LIST_EMPTY((n)->v6))
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define NAME_HAS_ADDRS(n) (NAME_HAS_V4(n) || NAME_HAS_V6(n))
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence * Fetches are broken out into A and AAAA types. In some cases,
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence * however, it makes more sense to test for a particular class of fetches,
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence * like V4 or V6 above.
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence * Note: since we have removed the support of A6 in adb, FETCH_A and FETCH_AAAA
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence * are now equal to FETCH_V4 and FETCH_V6, respectively.
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence#define NAME_FETCH_A(n) ((n)->fetch_a != NULL)
74cf566d92d610c2dc090a0dc7f77651c0fb0635David Lawrence#define NAME_FETCH_AAAA(n) ((n)->fetch_aaaa != NULL)
7dbf5a0b64237aa3052f04f4c8f7d56be8ec5d79Michael Graff#define NAME_FETCH(n) (NAME_FETCH_V4(n) || NAME_FETCH_V6(n))
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson * Find options and tests to see if there are addresses on the list.
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_WANTEVENT(fn) (((fn)->options & DNS_ADBFIND_WANTEVENT) != 0)
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_WANTEMPTYEVENT(fn) (((fn)->options & DNS_ADBFIND_EMPTYEVENT) != 0)
d257033612f3052265085e0d7fdc116c871a28c0Michael Graff#define FIND_AVOIDFETCHES(fn) (((fn)->options & DNS_ADBFIND_AVOIDFETCHES) \
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_STARTATZONE(fn) (((fn)->options & DNS_ADBFIND_STARTATZONE) \
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_HINTOK(fn) (((fn)->options & DNS_ADBFIND_HINTOK) != 0)
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_GLUEOK(fn) (((fn)->options & DNS_ADBFIND_GLUEOK) != 0)
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_HAS_ADDRS(fn) (!ISC_LIST_EMPTY((fn)->list))
b91bbaf50cf6d0c2cad7323720495165595e413bMichael Graff#define FIND_RETURNLAME(fn) (((fn)->options & DNS_ADBFIND_RETURNLAME) != 0)
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson * These are currently used on simple unsigned ints, so they are
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson * not really associated with any particular type.
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define WANT_INET(x) (((x) & DNS_ADBFIND_INET) != 0)
7bee275ebe250b5e1705a997e2ee3e685d146fbdAndreas Gustafsson#define WANT_INET6(x) (((x) & DNS_ADBFIND_INET6) != 0)
((o) & DNS_ADBFIND_STARTATZONE))
(r) == DNS_R_NCACHENXRRSET)
(r) == DNS_R_NXRRSET)
(r) == DNS_R_NCACHENXDOMAIN)
(r) == DNS_R_NXRRSET || \
(r) == DNS_R_HINTNXRRSET)
static const char *errnames[] = {
static inline dns_ttl_t
return (ttl);
static isc_result_t
int addr_bucket;
unsigned int findoptions;
goto fail;
goto fail;
fail:
if (new_addresses_added) {
return (ISC_R_SUCCESS);
return (result);
static isc_boolean_t
name = *n;
*n = NULL;
if (result)
return (result);
if (result)
return (result);
static isc_boolean_t
if (overmem) {
static inline isc_boolean_t
int bucket;
return (result);
static inline isc_boolean_t
int bucket;
return (result);
static isc_boolean_t
int bucket;
return (result);
static isc_boolean_t
int bucket;
if (result)
return (result);
static isc_boolean_t
int addr_bucket;
return (result);
static isc_result_t
unsigned int nlabels;
int order;
return (result);
return (result);
return (result);
return (result);
return (result);
NULL);
return (result);
return (result);
return (ISC_R_SUCCESS);
unsigned int addrs)
switch (evtype) {
if ((notify) != 0) {
if (wanted == 0)
if (process) {
static inline isc_boolean_t
return (result);
int bucket;
if (lock)
if (lock)
static inline isc_boolean_t
int bucket;
if (lock)
if (lock)
if (!destroy_entry)
return (result);
if (result)
return (result);
static inline dns_adbname_t *
return (NULL);
return (NULL);
return (name);
dns_adbname_t *n;
n = *name;
n->magic = 0;
static inline dns_adbnamehook_t *
return (NULL);
return (nh);
static inline dns_adbzoneinfo_t *
return (NULL);
return (NULL);
return (zi);
static inline dns_adbentry_t *
dns_adbentry_t *e;
isc_uint32_t r;
if (e == NULL)
return (NULL);
e->refcnt = 0;
e->flags = 0;
isc_random_get(&r);
e->expires = 0;
dns_adbentry_t *e;
e = *entry;
e->magic = 0;
static inline dns_adbfind_t *
dns_adbfind_t *h;
if (h == NULL)
return (NULL);
h->magic = 0;
h->partial_result = 0;
h->options = 0;
h->flags = 0;
return (NULL);
static inline dns_adbfetch_t *
dns_adbfetch_t *f;
if (f == NULL)
return (NULL);
f->magic = 0;
goto err;
goto err;
err:
return (NULL);
dns_adbfetch_t *f;
f = *fetch;
f->magic = 0;
static inline isc_boolean_t
static inline dns_adbaddrinfo_t *
return (NULL);
return (ai);
static inline dns_adbname_t *
int bucket;
return (adbname);
return (NULL);
static inline dns_adbentry_t *
int bucket;
return (entry);
return (NULL);
static isc_boolean_t
return (ISC_FALSE);
return (is_bad);
int bucket;
goto nextv4;
goto out;
goto nextv6;
goto out;
out:
static isc_boolean_t
return (result);
return (result);
return (result);
return (result);
return (result);
return (result);
static isc_boolean_t
return (result);
return (result);
if (result)
return (result);
static isc_boolean_t
return (result);
if (!result)
return (result);
static isc_boolean_t
return (result);
for (i = 0; i < CLEAN_BUCKETS; i++) {
== ISC_FALSE);
#ifdef DUMP_ADB_AFTER_CLEANING
return (ISC_R_NOMEMORY);
goto fail0b;
goto fail0c;
goto fail0d;
goto fail1;
for (i = 0; i < NBUCKETS; i++) {
for (i = 0; i < NBUCKETS; i++) {
goto fail2;
#define MPINIT(t, p, n) do { \
goto fail3; \
isc_mempool_setname((p), n); \
goto fail3;
goto fail3;
return (ISC_R_SUCCESS);
return (result);
if (need_exit_check) {
if (!need_check_exit)
if (need_check_exit)
int bucket;
unsigned int wanted_addresses;
unsigned int wanted_fetches;
unsigned int query_pending;
wanted_fetches = 0;
query_pending = 0;
if (now == 0)
return (ISC_R_NOMEMORY);
goto out;
goto out;
adbname);
goto post_copy;
adbname);
goto v6;
adbname);
goto post_copy;
goto fetch;
goto v6;
v6:
adbname);
goto fetch;
adbname);
goto post_copy;
goto fetch;
if (wanted_fetches != 0 &&
adbname);
adbname);
if (alias)
if (want_event) {
if (alias) {
goto out;
out:
if (want_event) {
return (result);
int bucket;
int bucket;
int unlock_bucket;
goto cleanup;
for (i = 0; i < NBUCKETS; i++)
for (i = 0; i < NBUCKETS; i++)
if (debug)
for (i = 0; i < NBUCKETS; i++)
for (i = 0; i < NBUCKETS; i++)
for (i = 0; i < NBUCKETS; i++) {
if (debug)
if (debug)
if (debug)
if (debug)
for (i = 0; i < NBUCKETS; i++) {
for (i = 0; i < NBUCKETS; i++)
for (i = 0; i < NBUCKETS; i++)
if (debug)
const char *tmpp;
case AF_INET:
case AF_INET6:
if (debug)
if (NAME_FETCH_A(n))
if (NAME_FETCH_AAAA(n))
static isc_result_t
switch (result) {
case DNS_R_GLUE:
case DNS_R_HINT:
case ISC_R_SUCCESS:
case DNS_R_NXDOMAIN:
case DNS_R_NXRRSET:
adbname);
adbname);
case DNS_R_NCACHENXDOMAIN:
case DNS_R_NCACHENXRRSET:
case DNS_R_CNAME:
case DNS_R_DNAME:
adbname);
return (result);
int bucket;
unsigned int address_type;
address_type = 0;
if (want_check_exit) {
goto out;
name);
goto check_result;
goto out;
out:
static isc_result_t
unsigned int options;
if (start_at_zone) {
adbname);
goto cleanup;
goto cleanup;
goto cleanup;
return (result);
int bucket;
goto unlock;
goto unlock;
return (ISC_R_SUCCESS);
int bucket;
unsigned int new_srtt;
int bucket;
int bucket;
goto unlock;
goto unlock;
return (result);
int bucket;
if (want_check_exit) {
for (i = 0; i < NBUCKETS; i++)
for (i = 0; i < NBUCKETS; i++)
#ifdef DUMP_ADB_AFTER_CLEANING
int bucket;
if (overmem) {