#include <config.h>#include <isc/buffer.h>#include <isc/log.h>#include <isc/hash.h>#include <isc/mem.h>#include <isc/mutex.h>#include <isc/platform.h>#include <isc/print.h>#include <isc/string.h>#include <isc/time.h>#include <isc/util.h>#include <dns/badcache.h>#include <dns/name.h>#include <dns/rdatatype.h>#include <dns/types.h>Go to the source code of this file.
Data Structures | |
| struct | dns_badcache |
| struct | dns_bcentry |
Defines | |
| #define | BADCACHE_MAGIC ISC_MAGIC('B', 'd', 'C', 'a') |
| #define | VALID_BADCACHE(m) ISC_MAGIC_VALID(m, BADCACHE_MAGIC) |
Typedefs | |
| typedef struct dns_bcentry | dns_bcentry_t |
Functions | |
| static isc_result_t | badcache_resize (dns_badcache_t *bc, isc_time_t *now, isc_boolean_t grow) |
| isc_result_t | dns_badcache_init (isc_mem_t *mctx, unsigned int size, dns_badcache_t **bcp) |
| void | dns_badcache_destroy (dns_badcache_t **bcp) |
| Allocate and initialize a badcache and store it in '*bcp'. | |
| void | dns_badcache_add (dns_badcache_t *bc, dns_name_t *name, dns_rdatatype_t type, isc_boolean_t update, isc_uint32_t flags, isc_time_t *expire) |
| Flush and then free badcache in 'bcp'. '*bcp' is set to NULL on return. | |
| isc_boolean_t | dns_badcache_find (dns_badcache_t *bc, dns_name_t *name, dns_rdatatype_t type, isc_uint32_t *flagp, isc_time_t *now) |
| Adds a badcache entry to the badcache 'bc' for name 'name' and type 'type'. If an entry already exists, then it will be updated if 'update' is ISC_TRUE. The entry will be stored with flags 'flags' and expiration date 'expire'. | |
| void | dns_badcache_flush (dns_badcache_t *bc) |
| Returns ISC_TRUE if a record is found in the badcache 'bc' matching 'name' and 'type', with an expiration date later than 'now'. If 'flagp' is not NULL, then '*flagp' is updated to the flags that were stored in the badcache entry. Returns ISC_FALSE if no matching record is found. | |
| void | dns_badcache_flushname (dns_badcache_t *bc, dns_name_t *name) |
| Flush the entire bad cache. | |
| void | dns_badcache_flushtree (dns_badcache_t *bc, dns_name_t *name) |
| Flush the bad cache of all entries at 'name'. | |
| void | dns_badcache_print (dns_badcache_t *bc, const char *cachename, FILE *fp) |
| Flush the bad cache of all entries at or below 'name'. | |
Definition in file badcache.c.
| #define BADCACHE_MAGIC ISC_MAGIC('B', 'd', 'C', 'a') |
| #define VALID_BADCACHE | ( | m | ) | ISC_MAGIC_VALID(m, BADCACHE_MAGIC) |
Definition at line 52 of file badcache.c.
Referenced by dns_badcache_add(), dns_badcache_find(), dns_badcache_flush(), dns_badcache_flushname(), dns_badcache_flushtree(), and dns_badcache_print().
| typedef struct dns_bcentry dns_bcentry_t |
Definition at line 37 of file badcache.c.
| static isc_result_t badcache_resize | ( | dns_badcache_t * | bc, | |
| isc_time_t * | now, | |||
| isc_boolean_t | grow | |||
| ) | [static] |
Definition at line 124 of file badcache.c.
References dns_badcache::count, dns_bcentry::expire, dns_bcentry::hashval, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_time_compare(), dns_name::length, dns_badcache::mctx, dns_bcentry::name, dns_bcentry::next, dns_badcache::size, and dns_badcache::table.
Referenced by dns_badcache_add().
| isc_result_t dns_badcache_init | ( | isc_mem_t * | mctx, | |
| unsigned int | size, | |||
| dns_badcache_t ** | bcp | |||
| ) |
Definition at line 67 of file badcache.c.
References BADCACHE_MAGIC, cleanup(), dns_badcache::count, DESTROYLOCK, isc_mem_attach(), isc_mem_get, isc_mem_putanddetach, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_badcache::lock, dns_badcache::magic, dns_badcache::mctx, dns_badcache::minsize, REQUIRE, dns_badcache::size, dns_badcache::sweep, and dns_badcache::table.
Referenced by dns_resolver_create(), and dns_view_create().
| void dns_badcache_destroy | ( | dns_badcache_t ** | bcp | ) |
Allocate and initialize a badcache and store it in '*bcp'.
Requires:
Definition at line 108 of file badcache.c.
References DESTROYLOCK, dns_badcache_flush(), isc_mem_put, isc_mem_putanddetach, dns_badcache::lock, dns_badcache::magic, dns_badcache::mctx, REQUIRE, dns_badcache::size, and dns_badcache::table.
Referenced by destroy().
| void dns_badcache_add | ( | dns_badcache_t * | bc, | |
| dns_name_t * | name, | |||
| dns_rdatatype_t | type, | |||
| isc_boolean_t | update, | |||
| isc_uint32_t | flags, | |||
| isc_time_t * | expire | |||
| ) |
Flush and then free badcache in 'bcp'. '*bcp' is set to NULL on return.
Requires:
Definition at line 161 of file badcache.c.
References badcache_resize(), buffer, cleanup(), dns_badcache::count, dns_name_copy(), dns_name_equal(), dns_name_hash(), dns_name_init(), dns_bcentry::expire, dns_bcentry::flags, dns_bcentry::hashval, isc_buffer_init, ISC_FALSE, isc_mem_get, isc_mem_put, ISC_R_SUCCESS, isc_time_compare(), isc_time_now(), isc_time_settoepoch(), ISC_TRUE, dns_name::length, dns_badcache::lock, LOCK, dns_badcache::mctx, dns_badcache::minsize, dns_bcentry::name, dns_bcentry::next, now, REQUIRE, dns_badcache::size, dns_badcache::table, dns_bcentry::type, UNLOCK, and VALID_BADCACHE.
Referenced by dns_resolver_addbadcache(), and ns_client_error().
| isc_boolean_t dns_badcache_find | ( | dns_badcache_t * | bc, | |
| dns_name_t * | name, | |||
| dns_rdatatype_t | type, | |||
| isc_uint32_t * | flagp, | |||
| isc_time_t * | now | |||
| ) |
Adds a badcache entry to the badcache 'bc' for name 'name' and type 'type'. If an entry already exists, then it will be updated if 'update' is ISC_TRUE. The entry will be stored with flags 'flags' and expiration date 'expire'.
Requires:
Definition at line 231 of file badcache.c.
References answer, dns_badcache::count, dns_name_equal(), dns_name_hash(), dns_bcentry::expire, dns_bcentry::flags, ISC_FALSE, isc_mem_put, isc_time_compare(), ISC_TRUE, dns_name::length, dns_badcache::lock, LOCK, dns_badcache::mctx, dns_bcentry::name, dns_bcentry::next, REQUIRE, dns_badcache::size, dns_badcache::sweep, dns_badcache::table, dns_bcentry::type, UNLOCK, and VALID_BADCACHE.
Referenced by dns_resolver_getbadcache(), and query_find().
| void dns_badcache_flush | ( | dns_badcache_t * | bc | ) |
Returns ISC_TRUE if a record is found in the badcache 'bc' matching 'name' and 'type', with an expiration date later than 'now'. If 'flagp' is not NULL, then '*flagp' is updated to the flags that were stored in the badcache entry. Returns ISC_FALSE if no matching record is found.
Requires:
Definition at line 292 of file badcache.c.
References dns_badcache::count, isc_mem_put, dns_name::length, dns_badcache::mctx, dns_bcentry::name, dns_bcentry::next, REQUIRE, dns_badcache::size, dns_badcache::table, and VALID_BADCACHE.
Referenced by dns_badcache_destroy(), dns_resolver_flushbadcache(), and dns_view_flushcache2().
| void dns_badcache_flushname | ( | dns_badcache_t * | bc, | |
| dns_name_t * | name | |||
| ) |
Flush the entire bad cache.
Requires:
Definition at line 310 of file badcache.c.
References dns_badcache::count, dns_name_equal(), dns_name_hash(), dns_bcentry::expire, ISC_FALSE, isc_mem_put, ISC_R_SUCCESS, isc_time_compare(), isc_time_now(), isc_time_settoepoch(), dns_name::length, dns_badcache::lock, LOCK, dns_badcache::mctx, dns_bcentry::name, dns_bcentry::next, now, REQUIRE, dns_badcache::size, dns_badcache::table, UNLOCK, and VALID_BADCACHE.
Referenced by dns_resolver_flushbadcache(), and dns_view_flushnode().
| void dns_badcache_flushtree | ( | dns_badcache_t * | bc, | |
| dns_name_t * | name | |||
| ) |
Flush the bad cache of all entries at 'name'.
Requires:
Definition at line 347 of file badcache.c.
References dns_badcache::count, dns_name_issubdomain(), dns_bcentry::expire, isc_mem_put, ISC_R_SUCCESS, isc_time_compare(), isc_time_now(), isc_time_settoepoch(), dns_name::length, dns_badcache::lock, LOCK, dns_badcache::mctx, dns_bcentry::name, dns_bcentry::next, now, REQUIRE, dns_badcache::size, dns_badcache::table, UNLOCK, and VALID_BADCACHE.
Referenced by dns_resolver_flushbadnames(), and dns_view_flushnode().
| void dns_badcache_print | ( | dns_badcache_t * | bc, | |
| const char * | cachename, | |||
| FILE * | fp | |||
| ) |
Flush the bad cache of all entries at or below 'name'.
Requires:
Definition at line 387 of file badcache.c.
References dns_badcache::count, dns_name_format(), DNS_NAME_FORMATSIZE, dns_rdatatype_format(), DNS_RDATATYPE_FORMATSIZE, dns_bcentry::expire, isc_mem_put, ISC_PLATFORM_QUADFORMAT, isc_time_compare(), isc_time_microdiff(), dns_name::length, dns_badcache::lock, LOCK, dns_badcache::mctx, dns_bcentry::name, namebuf, dns_bcentry::next, now, REQUIRE, dns_badcache::size, dns_badcache::table, TIME_NOW, dns_bcentry::type, UNLOCK, and VALID_BADCACHE.
Referenced by dns_resolver_printbadcache(), dns_view_dumpdbtostream(), and dumpdone().