master.c revision 6fda1577669dca9e0d8e4832e407bac34cc12de6
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
cb3e854e181373807f7f011e5050c1a8013b4841Brian Wellington * Permission to use, copy, modify, and distribute this software for any
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * purpose with or without fee is hereby granted, provided that the above
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * copyright notice and this permission notice appear in all copies.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
cb3e854e181373807f7f011e5050c1a8013b4841Brian Wellington * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
cb3e854e181373807f7f011e5050c1a8013b4841Brian Wellington * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington/* $Id: master.c,v 1.86 2000/12/07 20:15:49 marka Exp $ */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Grow the number of dns_rdatalist_t (RDLSZ) and dns_rdata_t (RDSZ) structures
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * by these sizes when we need to.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * RDLSZ reflects the number of different types with the same name expected.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * RDSZ reflects the number of rdata expected at a give name that can fit into
91cd0f93ad34d23e8b09dca337120f64fbe8f0a1Andreas Gustafsson * Target buffer size and minimum target size.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * MINTSIZ must be big enough to hold the largest rdata record.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * TSIZ >= MINTSIZ
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * max message size - header - root - type - class - ttl - rdlen
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define MINTSIZ (65535 - 12 - 1 - 2 - 2 - 4 - 2)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Size for tokens in the presentation format,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * The largest tokens are the base64 blocks in KEY and CERT records,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Largest key allowed is about 1372 bytes but
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * there is no fixed upper bound on CERT records.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * 2K is too small for some X.509s, 8K is overkill.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtontypedef ISC_LIST(dns_rdatalist_t) rdatalist_head_t;
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Master file loading state that persists across $INCLUDEs.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington dns_fixedname_t fixed[NBUFS]; /* working buffers */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington unsigned int in_use[NBUFS]; /* covert to bitmap? */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington /* Which fixed buffers we are using? */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington unsigned int loop_cnt; /* records per quantum,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * 0 => all. */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington /* Rate limit goo. */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington /* locked by lock */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define DNS_LCTX_MAGIC ISC_MAGIC('L','c','t','x')
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define DNS_LCTX_VALID(ctx) ISC_MAGIC_VALID(ctx, DNS_LCTX_MAGIC)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define DNS_LMGR_MAGIC ISC_MAGIC('L','m','g','r')
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define DNS_LMGR_VALID(ctx) ISC_MAGIC_VALID(ctx, DNS_LMGR_MAGIC)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonpushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t **ctxp);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtoncommit(dns_rdatacallbacks_t *, isc_lex_t *, rdatalist_head_t *, dns_name_t *,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtongrow_rdatalist(int, dns_rdatalist_t *, int, rdatalist_head_t *,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtongrow_rdata(int, dns_rdata_t *, int, rdatalist_head_t *, rdatalist_head_t *,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonload_quantum(isc_task_t *task, isc_event_t *event);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonloadmgr_start(isc_task_t *task, isc_event_t *event);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtonloadmgr_iattach(dns_loadmgr_t *source, dns_loadmgr_t **target);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define GETTOKEN(lexer, options, token, eol) \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = gettoken(lexer, options, token, eol, callbacks); \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington if ((token)->type == isc_tokentype_special) { \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = commit(callbacks, ctx->lex, ¤t_list, \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = commit(callbacks, ctx->lex, &glue_list, \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington isc_buffer_init(&target, target_mem, target_size); \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington "%s:%lu: file does not end with newline", \
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define CTX_COPYVAR(ctx, new, var) (new)->var = (ctx)->var
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtongettoken(isc_lex_t *lex, unsigned int options, isc_token_t *token,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington isc_boolean_t eol, dns_rdatacallbacks_t *callbacks)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington options |= ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | ISC_LEXOPT_DNSMULTILINE |
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = isc_lex_gettoken(lex, options, token);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington "isc_lex_gettoken() failed: %s",
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington /*NOTREACHED*/
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington "dns_master_load: %s:%lu: unexpected end of %s",
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellingtondns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target) {
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington REQUIRE(target != NULL && *target == NULL);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington INSIST(source->references != 0); /* Overflow? */
static isc_result_t
isc_region_t r;
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTED);
goto cleanup_ctx;
for (i = 0; i < NBUFS; i++) {
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
char *cp;
char mode;
int delta = 0;
unsigned int width;
name++;
if (r.length == 0)
return (ISC_R_NOSPACE);
return (DNS_R_SYNTAX);
if (n >= sizeof(fmt))
return (ISC_R_NOSPACE);
if (n >= sizeof(numbuf))
return (ISC_R_NOSPACE);
if (r.length == 0)
return (ISC_R_NOSPACE);
if (r.length == 0)
return (ISC_R_NOSPACE);
if (r.length == 0)
return (ISC_R_NOSPACE);
if (r.length == 0)
return (ISC_R_NOSPACE);
if (r.length == 0)
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
goto error_cleanup;
range);
goto insist_cleanup;
gtype);
goto insist_cleanup;
switch (type) {
case dns_rdatatype_ns:
case dns_rdatatype_ptr:
case dns_rdatatype_cname:
case dns_rdatatype_a:
case dns_rdatatype_aaaa:
gtype);
goto error_cleanup;
goto error_cleanup;
goto error_cleanup;
goto error_cleanup;
goto error_cleanup;
goto error_cleanup;
goto error_cleanup;
goto cleanup;
return (result);
static isc_result_t
int rdlcount = 0;
int rdlcount_save = 0;
int rdatalist_size = 0;
int rdcount = 0;
int rdcount_save = 0;
int rdata_size = 0;
int new_in_use;
unsigned int loop_cnt = 0;
goto log_and_cleanup;
if (read_till_eol)
if (read_till_eol)
result =
goto insist_and_cleanup;
if (ttl_offset != 0) {
goto insist_and_cleanup;
goto log_and_cleanup;
ctxp);
goto log_and_cleanup;
goto log_and_cleanup;
goto insist_and_cleanup;
goto insist_and_cleanup;
goto log_and_cleanup;
goto log_and_cleanup;
goto log_and_cleanup;
goto log_and_cleanup;
goto insist_and_cleanup;
goto insist_and_cleanup;
goto log_and_cleanup;
if (finish_origin) {
if (finish_include) {
goto log_and_cleanup;
goto log_and_cleanup;
if (current_has_delegation &&
goto log_and_cleanup;
rdcount = 0;
rdlcount = 0;
goto insist_and_cleanup;
type = 0;
rdclass = 0;
if (initialws) {
goto insist_and_cleanup;
== ISC_R_SUCCESS)
== ISC_R_SUCCESS) {
goto insist_and_cleanup;
goto insist_and_cleanup;
if (rdclass == 0 &&
== ISC_R_SUCCESS)
goto insist_and_cleanup;
goto insist_and_cleanup;
sizeof(classname1));
sizeof(classname2));
goto insist_and_cleanup;
goto log_and_cleanup;
goto insist_and_cleanup;
covers = 0;
mctx);
goto log_and_cleanup;
link);
rdcount++;
goto log_and_cleanup;
goto log_and_cleanup;
if (!done) {
goto cleanup;
return (result);
static isc_result_t
isc_region_t r;
int new_in_use;
&new);
return (result);
goto cleanup;
return (ISC_R_SUCCESS);
return (result);
return (result);
goto cleanup;
return (result);
goto cleanup;
goto cleanup;
if (queue)
if (!queue) {
return (result);
return (result);
goto done;
done:
return (result);
goto cleanup;
return (result);
return (result);
goto cleanup;
goto cleanup;
return (result);
goto cleanup;
goto cleanup;
return (result);
return (result);
return (result);
goto cleanup;
return (result);
return (result);
goto cleanup;
return (result);
return (result);
static dns_rdatalist_t *
int rdlcount = 0;
return (NULL);
rdlcount++;
rdlcount++;
return (new);
static dns_rdata_t *
int rdcount = 0;
return (NULL);
rdcount++;
rdcount++;
return (new);
static isc_result_t
return (ISC_R_SUCCESS);
if (!ignore) {
&dataset));
return (result);
return (ISC_R_SUCCESS);
static isc_boolean_t
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
static isc_result_t
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (result);
return (ISC_R_SUCCESS);
if (destroy)
if (destroy)