adb.c revision fbcf7bc351f2d42d338cb1fa29e59babd9bee94e
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * Copyright (C) 1999 Internet Software Consortium.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * Permission to use, copy, modify, and distribute this software for any
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * purpose with or without fee is hereby granted, provided that the above
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * copyright notice and this permission notice appear in all copies.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Implementation notes
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * --------------------
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * In handles, if task == NULL, no events will be generated, and no events
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * have been sent. If task != NULL but taskaction == NULL, an event has been
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * posted but not yet freed. If neigher are NULL, no event was posted.
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADB_VALID(x) ISC_MAGIC_VALID(x, DNS_ADB_MAGIC)
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBNAME_MAGIC 0x6164624e /* adbN. */
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBNAME_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBNAME_MAGIC)
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBNAMEHOOK_MAGIC 0x61644e48 /* adNH. */
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBNAMEHOOK_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBNAMEHOOK_MAGIC)
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBZONEINFO_MAGIC 0x6164625a /* adbZ. */
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBZONEINFO_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBZONEINFO_MAGIC)
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBENTRY_MAGIC 0x61646245 /* adbE. */
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff#define DNS_ADBENTRY_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBENTRY_MAGIC)
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff#define DNS_ADBFETCH_MAGIC 0x61646246 /* adbF. */
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff#define DNS_ADBFETCH_VALID(x) ISC_MAGIC_VALID(x, DNS_ADBFETCH_MAGIC)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Lengths of lists needs to be powers of two.
f00d96a15cdd11e764437f9359e67328631caaeaMichael Graff#define DNS_ADBNAMELIST_LENGTH 32 /* how many buckets for names */
f00d96a15cdd11e764437f9359e67328631caaeaMichael Graff#define DNS_ADBENTRYLIST_LENGTH 32 /* how many buckets for addresses */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#define FREE_ITEMS 16 /* free count for memory pools */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff#define FILL_COUNT 8 /* fill count for memory pools */
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff#define DNS_ADB_INVALIDBUCKET (-1) /* invalid bucket address */
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Grafftypedef ISC_LIST(dns_adbname_t) dns_adbnamelist_t;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafftypedef struct dns_adbnamehook dns_adbnamehook_t;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Grafftypedef struct dns_adbzoneinfo dns_adbzoneinfo_t;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafftypedef ISC_LIST(dns_adbentry_t) dns_adbentrylist_t;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int magic;
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff unsigned int irefcnt;
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff unsigned int erefcnt;
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Bucketized locks and lists for names.
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff dns_adbnamelist_t names[DNS_ADBNAMELIST_LENGTH];
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff isc_mutex_t namelocks[DNS_ADBNAMELIST_LENGTH];
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff isc_boolean_t name_sd[DNS_ADBNAMELIST_LENGTH];
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff unsigned int name_refcnt[DNS_ADBNAMELIST_LENGTH];
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff * Bucketized locks for entries.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff dns_adbentrylist_t entries[DNS_ADBENTRYLIST_LENGTH];
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff isc_mutex_t entrylocks[DNS_ADBENTRYLIST_LENGTH];
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int magic;
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff unsigned int magic;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * dns_adbnamehook_t
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * This is a small widget that dangles off a dns_adbname_t. It contains a
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * pointer to the address information about this host, and a link to the next
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * namehook that will contain the next address this host has.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int magic;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * dns_adbzoneinfo_t
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * This is a small widget that holds zone-specific information about an
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * address. Currently limited to lameness, but could just as easily be
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * extended to other types of information about zones.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int magic;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * An address entry. It holds quite a bit of information about addresses,
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * including edns state, rtt, and of course the address of the host.
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int magic;
439c0011e642fb1d26011116144af698125262dbMichael Graff unsigned int refcnt;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int flags;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff unsigned int srtt;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Internal functions (and prototypes).
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graffstatic inline dns_adbname_t *new_adbname(dns_adb_t *, dns_name_t *);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void free_adbname(dns_adb_t *, dns_adbname_t **);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbnamehook_t *new_adbnamehook(dns_adb_t *,
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void free_adbnamehook(dns_adb_t *, dns_adbnamehook_t **);
f36a81c88493985ee2d1c53cc6fe88f4b00dbbc8Michael Graffstatic inline dns_adbzoneinfo_t *new_adbzoneinfo(dns_adb_t *, dns_name_t *);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void free_adbzoneinfo(dns_adb_t *, dns_adbzoneinfo_t **);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbentry_t *new_adbentry(dns_adb_t *);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void free_adbentry(dns_adb_t *, dns_adbentry_t **);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbhandle_t *new_adbhandle(dns_adb_t *);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void free_adbhandle(dns_adb_t *, dns_adbhandle_t **);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbaddrinfo_t *new_adbaddrinfo(dns_adb_t *,
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbname_t *find_name_and_lock(dns_adb_t *, dns_name_t *,
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline dns_adbentry_t *find_entry_and_lock(dns_adb_t *,
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic void print_dns_name(FILE *, dns_name_t *);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic void print_namehook_list(FILE *, dns_adbname_t *);
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graffstatic void print_handle_list(FILE *, dns_adbname_t *);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic inline void inc_adb_irefcnt(dns_adb_t *, isc_boolean_t);
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graffstatic inline isc_boolean_t dec_adb_irefcnt(dns_adb_t *, isc_boolean_t);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic inline void inc_adb_erefcnt(dns_adb_t *, isc_boolean_t);
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graffstatic inline isc_boolean_t dec_adb_erefcnt(dns_adb_t *, isc_boolean_t);
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void inc_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void dec_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graffstatic inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic void clean_namehooks_at_name(dns_adb_t *, dns_adbname_t *);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic void clean_handles_at_name(dns_adbname_t *, isc_eventtype_t);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graffstatic isc_result_t construct_name(dns_adb_t *, dns_adbhandle_t *,
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graffstatic inline isc_boolean_t check_exit(dns_adb_t *);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic inline void
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffviolate_locking_hierarchy(isc_mutex_t *have, isc_mutex_t *want)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff if (isc_mutex_trylock(want) != ISC_R_SUCCESS) {
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graff * The ADB _MUST_ be locked before calling. Also, exit conditions must be
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graff * checked after calling this function.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffshutdown_names(dns_adb_t *adb, isc_boolean_t kill_fetches)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff (void)kill_fetches; /* XXX need to implement */
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff for (bucket = 0 ; bucket < DNS_ADBNAMELIST_LENGTH ; bucket++) {
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * Run through the list. For each name, clean up handles
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * found there, and cancel any fetches running. When
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * all the fetches are canceled, the name will destroy
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff clean_handles_at_name(name, DNS_EVENT_ADBSHUTDOWN);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff /* XXX TODO: cancel fetches */
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff /* if no fetches, kill! */
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff ISC_LIST_UNLINK(adb->names[bucket], name, link);
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff * Assumes the name bucket is locked.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffclean_namehooks_at_name(dns_adb_t *adb, dns_adbname_t *name)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * Clean up the entry if needed.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * Free the namehook
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff ISC_LIST_UNLINK(name->namehooks, namehook, link);
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff * Assumes the name bucket is locked.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffclean_handles_at_name(dns_adbname_t *name, isc_eventtype_t evtype)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * Unlink the handle from the name, letting the caller
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * call dns_adb_done() on it to clean it up later.
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graff && (isc_mempool_getallocated(adb->ahmp) == 0))
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffstatic inline void
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffinc_adb_irefcnt(dns_adb_t *adb, isc_boolean_t lock)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffdec_adb_irefcnt(dns_adb_t *adb, isc_boolean_t lock)
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graffstatic inline void
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffinc_adb_erefcnt(dns_adb_t *adb, isc_boolean_t lock)
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graffdec_adb_erefcnt(dns_adb_t *adb, isc_boolean_t lock)
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void
439c0011e642fb1d26011116144af698125262dbMichael Graffinc_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock)
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void
439c0011e642fb1d26011116144af698125262dbMichael Graffdec_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock)
439c0011e642fb1d26011116144af698125262dbMichael Graff ISC_LIST_UNLINK(adb->entries[bucket], entry, link);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graffnew_adbname(dns_adb_t *adb, dns_name_t *dnsname)
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff if (dns_name_dup(dnsname, adb->mctx, &name->name) != ISC_R_SUCCESS) {
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graffstatic inline void
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Grafffree_adbname(dns_adb_t *adb, dns_adbname_t **name)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff INSIST(name != NULL && DNS_ADBNAME_VALID(*name));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffnew_adbnamehook(dns_adb_t *adb, dns_adbentry_t *entry)
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graffstatic inline void
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Grafffree_adbnamehook(dns_adb_t *adb, dns_adbnamehook_t **namehook)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff INSIST(namehook != NULL && DNS_ADBNAMEHOOK_VALID(*namehook));
f36a81c88493985ee2d1c53cc6fe88f4b00dbbc8Michael Graffnew_adbzoneinfo(dns_adb_t *adb, dns_name_t *zone)
f36a81c88493985ee2d1c53cc6fe88f4b00dbbc8Michael Graff if (dns_name_dup(zone, adb->mctx, &zi->zone) != ISC_R_SUCCESS) {
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void
439c0011e642fb1d26011116144af698125262dbMichael Grafffree_adbzoneinfo(dns_adb_t *adb, dns_adbzoneinfo_t **zoneinfo)
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff INSIST(zoneinfo != NULL && DNS_ADBZONEINFO_VALID(*zoneinfo));
e51511aa3281f8dc384eb1283115c7f8d5c402aeMichael Graffstatic inline void
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Grafffree_adbentry(dns_adb_t *adb, dns_adbentry_t **entry)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff INSIST(entry != NULL && DNS_ADBENTRY_VALID(*entry));
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff INSIST(e->lock_bucket == DNS_ADB_INVALIDBUCKET);
519b4a1a27c8b767a57a981dda69a3c6394bd49dMichael Graff * public members
519b4a1a27c8b767a57a981dda69a3c6394bd49dMichael Graff * private members
519b4a1a27c8b767a57a981dda69a3c6394bd49dMichael Graff "isc_mutex_init failed in new_adbhandle()");
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_EVENT_INIT(&h->event, sizeof (isc_event_t), 0, 0, 0, NULL, NULL,
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graffstatic inline void
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Grafffree_adbfetch(dns_adb_t *adb, dns_adbfetch_t **fetch)
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff INSIST(fetch != NULL && DNS_ADBFETCH_VALID(*fetch));
439c0011e642fb1d26011116144af698125262dbMichael Graffstatic inline void
439c0011e642fb1d26011116144af698125262dbMichael Grafffree_adbhandle(dns_adb_t *adb, dns_adbhandle_t **handlep)
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff INSIST(handlep != NULL && DNS_ADBHANDLE_VALID(*handlep));
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff INSIST(handle->name_bucket == DNS_ADB_INVALIDBUCKET);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Copy bits from the entry into the newly allocated addrinfo. The entry
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * must be locked, and the reference count must be bumped up by one
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * if this function returns a valid pointer.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffnew_adbaddrinfo(dns_adb_t *adb, dns_adbentry_t *entry)
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graffstatic inline void
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Grafffree_adbaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **ainfo)
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff INSIST(ainfo != NULL && DNS_ADBADDRINFO_VALID(*ainfo));
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Search for the name. NOTE: The bucket is kept locked on both
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * success and failure, so it must always be unlocked by the caller!
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * On the first call to this function, *bucketp must be set to
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * DNS_ADB_INVALIDBUCKET.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafffind_name_and_lock(dns_adb_t *adb, dns_name_t *name, int *bucketp)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Search for the address. NOTE: The bucket is kept locked on both
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * success and failure, so it must always be unlocked by the caller.
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * On the first call to this function, *bucketp must be set to
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * DNS_ADB_INVALIDBUCKET. This will cause a lock to occur. On
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * later calls (within the same "lock path") it can be left alone, so
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * if this function is called multiple times locking is only done if
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * the bucket changes.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Grafffind_entry_and_lock(dns_adb_t *adb, isc_sockaddr_t *addr, int *bucketp)
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff if (isc_sockaddr_equal(addr, &entry->sockaddr))
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * Entry bucket MUST be locked!
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graffentry_is_bad_for_zone(dns_adb_t *adb, dns_adbentry_t *entry, dns_name_t *zone,
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * Has the entry expired?
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff * Order tests from least to most expensive.
439c0011e642fb1d26011116144af698125262dbMichael Graffcopy_namehook_list(dns_adb_t *adb, dns_adbhandle_t *handle,
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff dns_adbname_t *name, dns_name_t *zone, isc_stdtime_t now)
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff if (entry_is_bad_for_zone(adb, namehook->entry, zone, now))
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff addrinfo = new_adbaddrinfo(adb, namehook->entry);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * Found a valid entry. Add it to the handle's list.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff inc_entry_refcnt(adb, namehook->entry, ISC_FALSE);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff ISC_LIST_APPEND(handle->list, addrinfo, link);
439c0011e642fb1d26011116144af698125262dbMichael Graff handle->result = ISC_R_SUCCESS; /* all were copied */
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff isc_mutexblock_destroy(adb->entrylocks, DNS_ADBENTRYLIST_LENGTH);
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff isc_mutexblock_destroy(adb->namelocks, DNS_ADBNAMELIST_LENGTH);
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff isc_mem_put(adb->mctx, adb, sizeof (dns_adb_t));
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * Public functions.
fbcf7bc351f2d42d338cb1fa29e59babd9bee94eMichael Graffdns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Initialize things here that cannot fail, and especially things
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * that must be NULL for the error return to work properly.
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff result = isc_condition_init(&adb->shutdown_cond);
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff * Initialize the bucket locks for names and elements.
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff * May as well initialize the list heads, too.
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff result = isc_mutexblock_init(adb->namelocks, DNS_ADBNAMELIST_LENGTH);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff for (i = 0 ; i < DNS_ADBNAMELIST_LENGTH ; i++) {
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff for (i = 0 ; i < DNS_ADBENTRYLIST_LENGTH ; i++)
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff result = isc_mutexblock_init(adb->entrylocks, DNS_ADBENTRYLIST_LENGTH);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Memory pools
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff#define MPINIT(t, p, l, n) do { \
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff result = isc_mempool_create(mem, sizeof (t), &(p)); \
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff isc_mempool_associatelock((p), &adb->mplock); \
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbname_t, adb->nmp, ISC_TRUE, "adbname");
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbnamehook_t, adb->nhmp, ISC_TRUE, "adbnamehook");
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbzoneinfo_t, adb->zimp, ISC_TRUE, "adbzoneinfo");
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbentry_t, adb->emp, ISC_TRUE, "adbentry");
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbhandle_t, adb->ahmp, ISC_TRUE, "adbhandle");
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff MPINIT(dns_adbaddrinfo_t, adb->aimp, ISC_TRUE, "adbaddrinfo");
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff MPINIT(dns_adbfetch_t, adb->afmp, ISC_TRUE, "adbfetch");
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Normal return.
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff isc_mutexblock_destroy(adb->entrylocks, DNS_ADBENTRYLIST_LENGTH);
3024dbecbac365171bc6de0f3fa04951d6558be3Michael Graff isc_mutexblock_destroy(adb->namelocks, DNS_ADBNAMELIST_LENGTH);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff REQUIRE(adbx != NULL && DNS_ADB_VALID(*adbx));
439c0011e642fb1d26011116144af698125262dbMichael Graffdns_adb_lookup(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
439c0011e642fb1d26011116144af698125262dbMichael Graff void *arg, dns_name_t *name, dns_name_t *zone,
439c0011e642fb1d26011116144af698125262dbMichael Graff * Look up the name in our internal database.
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * Possibilities: Note that these are not always exclusive.
439c0011e642fb1d26011116144af698125262dbMichael Graff * No name found. In this case, allocate a new name header and
439c0011e642fb1d26011116144af698125262dbMichael Graff * an initial namehook or two. If any of these allocations
439c0011e642fb1d26011116144af698125262dbMichael Graff * fail, clean up and return ISC_R_NOMEMORY.
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * Name found, valid addresses present. Allocate one addrinfo
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * structure for each found and append it to the linked list
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * of addresses for this header.
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * Name found, queries pending. In this case, if a task was
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * passed in, allocate a job id, attach it to the name's job
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * list and remember to tell the caller that there will be
50b5857f1ad137624a18ce67b26b9941e316b007Michael Graff * more info coming later.
439c0011e642fb1d26011116144af698125262dbMichael Graff * Look things up in our database first.
439c0011e642fb1d26011116144af698125262dbMichael Graff adbname = find_name_and_lock(adb, name, &bucket);
439c0011e642fb1d26011116144af698125262dbMichael Graff * Found! Run through the name and copy out the bits we are
439c0011e642fb1d26011116144af698125262dbMichael Graff * interested in. If we cannot copy at least one address, return
439c0011e642fb1d26011116144af698125262dbMichael Graff * ISC_R_NOMEMORY, otherwise copy out what we can and set the
439c0011e642fb1d26011116144af698125262dbMichael Graff * missing_data bit in the header.
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff copy_namehook_list(adb, handle, adbname, zone, now);
439c0011e642fb1d26011116144af698125262dbMichael Graff * Attach to the name's query list if there are queries
439c0011e642fb1d26011116144af698125262dbMichael Graff * already running.
bb143613cf26e0f27dfd9caf1a7336065d064b26Michael Graff if (!ISC_LIST_EMPTY(adbname->fetches) && (task != NULL)) {
439c0011e642fb1d26011116144af698125262dbMichael Graff ISC_LIST_APPEND(adbname->handles, handle, link);
439c0011e642fb1d26011116144af698125262dbMichael Graff * Nothing found. Allocate a new adbname structure for this name
439c0011e642fb1d26011116144af698125262dbMichael Graff * and look in the database for details. If the database has
439c0011e642fb1d26011116144af698125262dbMichael Graff * nothing useful, start a fetch if we can.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * Try to populate the name from the database and/or start fetches.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * If this function returns ISC_R_SUCCESS at least ONE new bit
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * of data was added, and/or fetches were started. If nothing new
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * can ever be found it will return DNS_R_NOMEMORY more than likely.
29f28fe573d4b3b318b3b026d567c1eb86738015Michael Graff result = construct_name(adb, handle, name, zone, adbname, bucket, now);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff ISC_LIST_PREPEND(adb->names[bucket], adbname, link);
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * If anything other than success is returned, free the name
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * (since it will have nothing useful in it) and return via the
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * failure return.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * If the name isn't on a list it means we allocated it here, and it
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * should be killed.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * "goto out" if the handle will be returned to the caller. This
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * is a non-fatal return, since it will give the caller a handle
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * at the very least.
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graffdns_adb_deletename(dns_adb_t *adb, dns_name_t *host)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Find the name.
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff name = find_name_and_lock(adb, host, &name_bucket);
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff * If any handles are attached to this name, notify them that things
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * are going away by canceling their requests.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff clean_handles_at_name(name, DNS_EVENT_ADBNAMEDELETED);
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff * If fetches are running for this name, cancel them all.
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Loop through the name and kill any namehooks and entries they
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff ISC_LIST_UNLINK(adb->names[name_bucket], name, link);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff if (adb->name_sd[name_bucket] && (adb->name_refcnt[name_bucket] == 0))
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graffdns_adb_insert(dns_adb_t *adb, dns_name_t *host, isc_sockaddr_t *addr)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff int name_bucket, addr_bucket; /* unlock if != DNS_ADB_INVALIDBUCKET */
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * First, see if the host is already in the database. If it is,
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * don't make a new host entry. If not, copy the name and name's
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * contents into our structure and allocate what we'll need
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * to attach things together.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff name = find_name_and_lock(adb, host, &name_bucket);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Now, while keeping the name locked, search for the address.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Three possibilities: One, the address doesn't exist.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Two, the address exists, but we aren't linked to it.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Three, the address exists and we are linked to it.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * (1) causes a new entry and namehook to be created.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * (2) causes only a new namehook.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * (3) is an error.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff entry = find_entry_and_lock(adb, addr, &addr_bucket);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Case (1): new entry and namehook.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Case (3): entry exists, we're linked.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Case (2): New namehook, link to entry from above.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_LIST_APPEND(name->namehooks, namehook, link);
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff * If needed, string up the name and entry.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_LIST_PREPEND(adb->names[name_bucket], name, link);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff ISC_LIST_PREPEND(adb->entries[addr_bucket], entry, link);
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff REQUIRE(handlep != NULL && DNS_ADBHANDLE_VALID(*handlep));
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * We need to get the adbname's lock to unlink the handle.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff violate_locking_hierarchy(&handle->lock, &adb->namelocks[bucket]);
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff ISC_LIST_UNLINK(handle->adbname->handles, handle, link);
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff * The handle doesn't exist on any list, and nothing is locked.
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff * Return the handle to the memory pool, and decrement the adb's
6d14fe95e9ea5bbc5e863e5aab4618f7b3dbcc0fMichael Graff * reference count.
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Lock the adb itself, lock all the name buckets, then lock all
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * the entry buckets. This should put the adb into a state where
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * nothing can change, so we can iterate through everything and
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * print at our leasure.
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff fprintf(f, "erefcnt %u, irefcnt %u\n", adb->erefcnt, adb->irefcnt);
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBNAMELIST_LENGTH ; i++)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBENTRYLIST_LENGTH ; i++)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Dump the names
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBNAMELIST_LENGTH ; i++) {
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Dump the entries
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBENTRYLIST_LENGTH ; i++) {
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff fprintf(f, "\tWRONG BUCKET! lock_bucket %d\n",
a385f150bb21b8b81f70ed7df545357a83f1da82Michael Graff fprintf(f, "\t%p: refcnt %u flags %08x goodness %d"
a9ece9973c35d4d780338e89e288fb6a59575324Michael Graff " srtt %u addr %s\n",
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff * Unlock everything
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBENTRYLIST_LENGTH ; i++)
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff for (i = 0 ; i < DNS_ADBNAMELIST_LENGTH ; i++)
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graffdns_adb_dumphandle(dns_adb_t *adb, dns_adbhandle_t *handle, FILE *f)
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff * Not used currently, in the API Just In Case we
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff * want to dump out the name and/or entries too.
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff fprintf(f, "\tquery_pending %d, result %d (%s)\n",
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff fprintf(f, "\tname_bucket %d, name %p, event sender %p\n",
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff handle->name_bucket, handle->adbname, handle->event.sender);
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff tmpp = inet_ntop(AF_INET, &sa->type.sin.sin_addr,
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff tmpp = inet_ntop(AF_INET6, &sa->type.sin6.sin6_addr,
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff fprintf(f, "\t\tentry %p, flags %08x goodness %d"
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff " srtt %u addr %s\n",
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff ai->entry, ai->flags, ai->goodness, ai->srtt, tmpp);
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff isc_buffer_init(&b, buf, sizeof (buf) - 1, ISC_BUFFERTYPE_TEXT);
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff fprintf(f, buf); /* safe, since names < 256 chars, and we memset */
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff fprintf(f, "\t\tHook %p -> entry %p\n", nh, nh->entry);
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graffprint_handle_list(FILE *f, dns_adbname_t *name)
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * On entry, "bucket" refers to a locked name bucket, "handle" is not NULL,
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * and "name" is the name we are looking for. We will allocate an adbname
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * and return a pointer to it in *adbnamep.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * If we return ISC_R_SUCCESS, the new name will have been allocated, and
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * perhaps some namehooks will have been filled in with valid entries, and
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff * perhaps some fetches have been started.
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graffconstruct_name(dns_adb_t *adb, dns_adbhandle_t *handle, dns_name_t *name,
29f28fe573d4b3b318b3b026d567c1eb86738015Michael Graff dns_name_t *zone, dns_adbname_t *adbname, int bucket,
4d727d86b245063f00c5bfd98d138a63e0b7de6dMichael Graff dns_adbentry_t *foundentry; /* NO CLEAN UP! */
29f28fe573d4b3b318b3b026d567c1eb86738015Michael Graff use_hints = dns_name_equal(zone, dns_rootname);
29f28fe573d4b3b318b3b026d567c1eb86738015Michael Graff result = dns_view_find(adb->view, name, dns_rdatatype_a,
4d727d86b245063f00c5bfd98d138a63e0b7de6dMichael Graff foundentry = find_entry_and_lock(adb, &sockaddr,
4d727d86b245063f00c5bfd98d138a63e0b7de6dMichael Graff ISC_LIST_APPEND(adbname->namehooks, nh, link);
f00d96a15cdd11e764437f9359e67328631caaeaMichael Graffdns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr, dns_name_t *zone,
f00d96a15cdd11e764437f9359e67328631caaeaMichael Graff ISC_LIST_PREPEND(addr->entry->zoneinfo, zi, link);
ca924f706b53b895a662de8345d88437b23b8f01Michael Graffdns_adb_adjustgoodness(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
ca924f706b53b895a662de8345d88437b23b8f01Michael Graff if (old_goodness > INT_MAX - goodness_adjustment)
ca924f706b53b895a662de8345d88437b23b8f01Michael Graff new_goodness = old_goodness + goodness_adjustment;
ca924f706b53b895a662de8345d88437b23b8f01Michael Graff if (old_goodness < INT_MIN - goodness_adjustment)
ca924f706b53b895a662de8345d88437b23b8f01Michael Graff new_goodness = old_goodness + goodness_adjustment;
beb2b4f19624af46230a8e3df97e54d6c596573eMichael Graffdns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
beb2b4f19624af46230a8e3df97e54d6c596573eMichael Graff new_srtt = (addr->entry->srtt * (factor - 1) + rtt) / factor;