zone.c revision 39073e9734e5e0ebb88ab9e3b14a85b7a0b9578b
5fa46bc91672ef5737aee6f99763161511566c24Tinderbox User * Copyright (C) 1999 Internet Software Consortium.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * copyright notice and this permission notice appear in all copies.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews /* $Id: zone.c,v 1.19 1999/10/13 23:32:02 marka Exp $ */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington/* XXX remove once config changes are in place */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define dns_zone_uptodate(x) dns_zone_logerror(x, "dns_zone_uptodate")
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtontypedef enum {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LINK(struct dns_zone_checkservers) link;
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* Unlocked */
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence * XXX merge w/ updatelog to
571688b02f955f6304649866e768b1f81739cbedBrian Wellington * locate transaction log
23f64ea0dcd7f5b7094ae6ade2a002fb7dde1466Brian Wellington /* Access Control Lists */
557bcc2092642b2d4668c9b08872c9f2bb88bddbMark Andrews ISC_LIST(dns_zone_checkservers_t) checkservers;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_FLAG(z,f) (((z)->flags & (f)) != 0)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* XXX MPA these may need to go back into zone.h */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_REFRESH 0x00000001U /* refresh check in progress */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_NEEDDUMP 0x00000002U /* zone need consolidation */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_SERVERS 0x00000004U /* servers check in progress */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_PARENTS 0x00000008U /* parents check in progress */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_CHILDREN 0x00000010U /* child check in progress */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington#define DNS_ZONE_F_LOADED 0x00000020U /* database has loaded */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington#define DNS_ZONE_F_EXITING 0x00000040U /* zone is being destroyed */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington#define DNS_ZONE_F_EXPIRED 0x00000080U /* zone has expired */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington#define DNS_ZONE_F_NEEDREFRESH 0x00000100U /* refresh check needed */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_F_UPTODATE 0x00000200U /* zone contents are
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * uptodate */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington#define DNS_ZONE_OPTION(z,o) ((((z)->setoptions & (o)) != 0) ? \
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington (((z)->options & (o)) != 0) : \
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void refresh_callback(isc_task_t *, isc_event_t *);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void zone_shutdown(isc_task_t *, isc_event_t *);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void soa_query(dns_zone_t *, isc_taskaction_t);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic dns_result_t zone_settimer(dns_zone_t *, isc_stdtime_t);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic dns_result_t dns_notify(dns_name_t *, isc_sockaddr_t *, dns_rdatatype_t,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington dns_rdataclass_t, isc_sockaddr_t *, isc_mem_t *);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void checkservers_callback(isc_task_t *task, isc_event_t *event);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void dns_zone_logerror(dns_zone_t *zone, const char *msg, ...);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic int message_count(dns_message_t *msg, dns_section_t section,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void sockaddr_fromaddr(isc_sockaddr_t *sockaddr, dns_c_addr_t *a,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void add_address_tocheck(dns_message_t *msg,
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonextern void dns_zone_transfer_in(dns_zone_t *zone);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic void record_serial(void);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic isc_boolean_t dns_zone_equal(dns_zone_t *, dns_zone_t *);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtonstatic char * dns_zone_tostr(dns_zone_t *zone);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington *** Public functions.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_sockaddr_fromin6(&sockaddr_any, &in6addr_any, 0);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington "isc_mutex_init() failed: %s",
23f64ea0dcd7f5b7094ae6ade2a002fb7dde1466Brian Wellington /* XXX MPA check that all elements are initialised */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington zone->references = 1; /* Implicit attach. */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington printf("create: %p: %s: references = %d\n", zone, dns_zone_tostr(zone),
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* managed objects */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* order is important */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (DNS_ZONE_FLAG(zone, DNS_ZONE_F_REFRESH))
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_resolver_destroyfetch(zone->res, &zone->fetch);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* unmanaged objects */
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson zone->check_names = dns_c_severity_ignore;
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson dns_c_ipmatchlist_delete(NULL, &zone->update_acl);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson dns_c_ipmatchlist_delete(NULL, &zone->query_acl);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson dns_c_ipmatchlist_delete(NULL, &zone->xfr_acl);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson dns_name_free(&zone->origin, zone->mctx);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson /* last stuff */
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson isc_mem_put(zone->mctx, zone, sizeof *zone);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater * Single shot.
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_setclass(dns_zone_t *zone, dns_rdataclass_t rdclass) {
daa73eae708d568d453e6082e0890d35886a9e0fMark Andrews REQUIRE(zone->rdclass == dns_rdataclass_none ||
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson * Single shot.
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_settype(dns_zone_t *zone, dns_zonetype_t type) {
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson REQUIRE(zone->type == dns_zone_none || zone->type == type);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_setdbtype(dns_zone_t *zone, char *db_type) {
a4c351fcef77fb332e3cb20253fb96556a414a17Brian Wellington zone->db_type = isc_mem_strdup(zone->mctx, db_type);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_setorigin(dns_zone_t *zone, char *origin) {
6b79e960e6ba2991aeb02a6c39af255ab7f06d99Mark Andrews isc_buffer_init(&buffer, origin, strlen(origin), ISC_BUFFERTYPE_TEXT);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson result = dns_name_fromtext(dns_fixedname_name(&fixed),
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson result = dns_name_dup(dns_fixedname_name(&fixed), zone->mctx,
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_setdatabase(dns_zone_t *zone, const char *database) {
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson isc_mem_free(zone->mctx, zone->database);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington zone->database = isc_mem_strdup(zone->mctx, database);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafssondns_zone_setupdatelog(dns_zone_t *zone, char *updatelog) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington zone->updatelog = isc_mem_strdup(zone->mctx, updatelog);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtondns_zone_setixfrlog(dns_zone_t *zone, const char *ixfrlog) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington zone->ixfrlog = isc_mem_strdup(zone->mctx, ixfrlog);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington REQUIRE(dns_name_countlabels(&zone->origin) != 0);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /*FALLTHROUGH*/
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington REQUIRE(zone->rdclass != dns_rdataclass_none);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington REQUIRE(zone->rdclass == dns_rdataclass_none);
307ba34fa07db768c3a899844f248a2c1d7dcc7fAndreas Gustafsson if (isc_stdtime_get(&now) != ISC_R_SUCCESS) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_create(zone->mctx, zone->db_type,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Initiate zone transfer? We may need a error code that
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * indicates that the "permanent" form does not exist.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * XXX better error feedback to log.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Apply update log to zone iff we are not generating it.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (zone->ixfrlog != NULL && zone->diff_on_reload == ISC_FALSE) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_journal_rollforward(zone->mctx, db, zone->ixfrlog);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (result != DNS_R_SUCCESS && result != DNS_R_NOTFOUND &&
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Obtain ns and soa counts for top of zone.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_findnode(db, &zone->origin, ISC_FALSE, &node);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_findrdataset(db, node, version,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_findrdataset(db, node, version,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_db_closeversion(db, &version, ISC_FALSE);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Master / Slave / Stub zones require both NS and SOA records at
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * the top of the zone.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Hint zones only require NS records.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Cache zones have no reqirements.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington zone->expiretime = now /*XXX*/ + zone->expire;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington zone->refreshtime = now + zone->refresh /*XXX*/;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_zone_replacedb(zone, db, ISC_FALSE);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington unsigned int i;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* XXX MPA */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * get NS list from database, add in notify also list
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_db_currentversion(zone->top, &version);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_findnode(zone->top, zonename, ISC_FALSE, &node);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_findrdataset(zone->top, node, version,
229ce407c359b0b641759ba1fc4a5fa2054a44daBrian Wellington result = dns_rdata_tostruct(&rdata, &ns, zone->mctx);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_name_init(&checkservers->server, NULL);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_zone_attach(zone, &checkservers->zone);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington dns_resolver_attach(zone->res, &checkservers->res);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* XXX lookup A/AAAA/A6 records */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington dns_db_closeversion(zone->top, &version, ISC_FALSE);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Foreach NS in NS list perform a non-recursive query to obtain
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * NS list for zone (remove self from list).
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * callback to check:
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If NXDOMAIN -> log error.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If NODATA -> log error.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * If referral -> log error.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * If non-auth -> log error.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Compare NS list returned with server list if not identical
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * log error if current list is at least 3 x refresh old.
5e387b9ce6bafdfadedb5b34e4c33a4404e5d589Brian Wellington * Compare glue A/AAAA/A6 records.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Foreach NS in NS list perform a non-recursive query to obtain
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * SOA record for zone (remove self from list).
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt * callback to check:
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt * If NXDOMAIN -> log error.
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt * If NODATA -> log error.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If referral -> log error.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If no-auth -> log error.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Compare SOA serial with ixfr list and if older that 3x refresh
77ac297199fc44809d9628558223627c10ae3f31Brian Wellington checkservers = isc_mem_get(zone->mctx, sizeof *checkservers);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_name_init(&checkservers->server, NULL);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_zone_attach(zone, &checkservers->zone);
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson dns_resolver_attach(zone->res, &checkservers->res);
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews ISC_LIST_APPEND(zone->checkservers, checkservers, link);
a4c351fcef77fb332e3cb20253fb96556a414a17Brian Wellington dns_resolver_createfetch(zone->res, zonename, dns_rdatatype_ns,
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrewscheckservers_callback(isc_task_t *task, isc_event_t *event) {
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews dns_fetchdoneevent_t *devent = (dns_fetchdoneevent_t *)event;
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews dns_zone_checkservers_t *checkservers = event->arg;
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews master = isc_sockaddr_totext(&zone->masters[zone->curmaster],
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews /* timeout */
6e93e6ea4557291e847aced6a88adcdf39f06843Andreas Gustafsson "unable to obtain address for (%s)");
75e1e12f48012505699f504cfa364260cb2bc1afBrian Wellington "unable to obtain %s RRset from %s"
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington add_address_tocheck(msg, checkservers, dns_rdatatype_a6);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_resolver_createfetch(res, name, dns_rdatatype_aaaa,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington add_address_tocheck(msg, checkservers, dns_rdatatype_a6);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_resolver_createfetch(res, name, dns_rdatatype_a,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington add_address_tocheck(msg, checkservers, dns_rdatatype_a);
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews /* make NS query to address */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_resolver_createfetch(res, name, dns_rdatatype_ns,
fefe1106d96d3a89b21315f665b36a67cdea3840Mark Andrews "server %s (%s) unexpected rcode = %.*s",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (msg->counts[DNS_SECTION_ANSWER] == 0) {
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews "server %s (%s) referral response");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington "server %s (%s) type = %s NODATA response");
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews "server %s (%s) not authorative");
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews /* compare NS RR sets */
85fcd0b9b2d80be4646187d7094e5644a52e3263Mark Andrews /* make soa query to address */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_resolver_createfetch(res, name, dns_rdatatype_soa,
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews /* compare SOA RR sets */
75582adac73202213d936dc0850f1c9cf47d6cbeMark Andrews UNEXPECTED_ERROR(__FILE__, __LINE__, "unexpected state");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington ISC_LIST_UNLINK(zone->checkservers, checkservers, link);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_mem_put(mctx, checkservers, sizeof *checkservers);
0a45f098e446a7f41c2a71d9dd0fd8f459b49c34Brian Wellingtoncmp_soa(dns_message_t *msg, dns_zone_t *zone, char *server) {
c302b021cc65cc9a358a9a1cbe48de12364f4cb6Brian Wellington * extract SOA from message
b1b0dca1464a11b8a63623e8567e744dccfbcb41Tatuya JINMEI 神明達哉 result = dns_message_findname(msg, DNS_SECTION_ANSWER,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington "Unable to extract SOA from answer: %s",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_rdata_tostruct(&rdata, &msgsoa, zone->mctx);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington "More that one SOA record returned: %s",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Get SOA record for zone.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_find(zone->top, &zone->origin,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington NULL, dns_rdatatype_soa, dns_rdatatype_none,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_rdataset_first(&zonerdataset);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_rdataset_current(&zonerdataset, &rdata);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_rdata_tostruct(&rdata, &msgsoa, zone->mctx);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_zone_logerror(zone, "More that one SOA in zone");
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Check SOA contents. If serials do not match check to see
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * if the slave is ahead of us (i.e. we have reset the serial
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If the serials do match then check the other values for
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * consistancy.
cfcb0881d12db2b7cb33475b7d20ac6c9015203bMark Andrews if (!isc_serial_lt(msgsoa.serial, zonesoa.serial)) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington "slave serial not less than or equal to zone serial: %s",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_name_compare(&msgsoa.origin, &zonesoa.origin) != 0 ||
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_name_compare(&msgsoa.mname, &zonesoa.mname) != 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_zone_logerror(zone, "SOA contents differ: %s",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtonadd_address_tocheck(dns_message_t *msg, dns_zone_checkservers_t *checkservers,
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson if (msg->counts[DNS_SECTION_QUESTION] != 0 ||
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_message_findname(msg, DNS_SECTION_QUESTION,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_sockaddr_fromin(&sockaddr, &a.in_addr, 0);
7a6f285bc933d08353d2f18290c85def575b6e57Andreas Gustafsson isc_sockaddr_fromin6(&sockaddr, &a6.in6_addr, 0);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington /* XXX MPA */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Obtain a parent NS list.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Remove LSL from zone name. Check to see if we are serving
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * zone otherwise make non-recursive query for NS set of
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * of given name. Follow referral until NXDOMAIN, NODATA or
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * answer is found. If NXDOMAIN or NODATA remove next LSL
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * and repeat.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * If self in NS list check masked NS list in parent against zone
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Foreach NS on parent NS list make non recursive query for NS set
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * of current zone (removed self from list if required).
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Check NS list return for agreement with zone's NS list.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* XXX MPA */
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * For each child zone obtain NS list from parent zone.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * For each NS in list send non-recursive query for child zone's
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * NS list for zone.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * If NXDOMAIN is returned log error.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * If NODATA is return log error.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * If referral is return log error.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * If non-auth is return log error.
6e2871232f7ede047799480370aff444be1f5a13Automatic Updater * If NS list disagree's with parents NS list log error.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington /* XXX MPA */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * For each glue record in this zone, check with an authorative
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * server for the zone to ensure that there have not been any
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellingtondns_zone_attach(dns_zone_t *source, dns_zone_t **target) {
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington REQUIRE(target != NULL && *target == NULL);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington printf("%p: %s: references = %d\n", source, dns_zone_tostr(source),
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington printf("\t%p: %s: references = %d\n", zone, dns_zone_tostr(zone),
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_buffer_init(&tbuf, outbuf, sizeof(outbuf) - 1,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (dns_name_countlabels(&zone->origin) > 0) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_name_totext(&zone->origin, ISC_FALSE, &tbuf);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strncpy(outbuf, "<name conversion failed>",
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington strncpy(outbuf, "<unnamed zone>", sizeof outbuf);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington REQUIRE(zonep != NULL && DNS_ZONE_VALID(*zonep));
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington printf("%p: %s: references = %d\n", zone, dns_zone_tostr(zone),
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_setoption(dns_zone_t *zone, unsigned int option, isc_boolean_t value)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_clearoption(dns_zone_t *zone, unsigned int option) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_getoptions(dns_zone_t *zone, unsigned int *options,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_adddbarg(dns_zone_t *zone, char *arg) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Allocate new 'db_argv' and set last to be copy of 'arg'.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington new = isc_mem_get(zone->mctx, (zone->db_argc + 1) * sizeof *new);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington new[zone->db_argc] = isc_mem_strdup(zone->mctx, arg);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Copy old 'db_argv' if required the free it.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington memcpy(new, zone->db_argv, zone->db_argc * sizeof *new);
a03848252fa85734ca75beae3d0b01bb503c0a8bMark Andrews unsigned int i;
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington isc_mem_free(zone->mctx, zone->db_argv[i]);
793814f80703afdd69b59ade91e63efa81ae4178Evan Huntdns_zone_setxfrsource(dns_zone_t *zone, isc_sockaddr_t *xfrsource) {
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉dns_zone_addnotify(dns_zone_t *zone, isc_sockaddr_t *notify) {
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt new = isc_mem_get(zone->mctx, (zone->notifycnt + 1) * sizeof *new);
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt memcpy(new, zone->notify, zone->notifycnt * sizeof *new);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_addmaster(dns_zone_t *zone, isc_sockaddr_t *master) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington new = isc_mem_get(zone->mctx, (zone->masterscnt + 1) * sizeof *new);
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington memcpy(new, zone->masters, zone->masterscnt * sizeof *new);
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington while (DNS_ZONE_FLAG(zone, DNS_ZONE_F_REFRESH)) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellingtondns_zone_getdb(dns_zone_t *zone, dns_db_t **dpb) {
f24c135e09214c3843a49fd32ebef2f6a436ba8eBrian Wellington * Co-ordinates the starting of routine jobs.
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington if (isc_stdtime_get(&now) != ISC_R_SUCCESS)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Expire check.
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Up to date check.
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉 !DNS_ZONE_FLAG(zone, DNS_ZONE_F_REFRESH))
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Do we need to consolidate the backing store?
a012d6dbfb100390efa7d0d4be64ada0210b09ddBrian Wellington DNS_ZONE_FLAG(zone, DNS_ZONE_F_NEEDDUMP)) {
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington * Check servers for zone.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington DNS_ZONE_OPTION(zone, DNS_ZONE_O_SERVERS) &&
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Check parent servers for zone.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington DNS_ZONE_OPTION(zone, DNS_ZONE_O_PARENTS) &&
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Check child servers for zone.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington DNS_ZONE_OPTION(zone, DNS_ZONE_O_CHILDREN) &&
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington if (DNS_ZONE_FLAG(zone, DNS_ZONE_F_NEEDDUMP))
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington dns_zone_setrefresh(zone, DEFAULT_REFRESH, DEFAULT_RETRY);
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington if (isc_stdtime_get(&now) != ISC_R_SUCCESS)
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * Set DNS_ZONE_F_REFRESH so that there is only one refresh operation
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * in progress at the one time.
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington * Set the next refresh time as if refresh check has failed.
60b90a37f41ab7607762d0e9791e79bd19eae4f4Brian Wellington * If we are successful it will be reset using zone->refresh.
b7cd261f2fca2c7138cdc6ae8ee434e9c0031303Brian Wellington /* initiate soa query */
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_db_currentversion(zone->top, &version);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_createiterator(zone->top, ISC_FALSE, &dbiterator);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_dbiterator_current(dbiterator, &node, name);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington if (result != DNS_R_SUCCESS && result != DNS_R_NEWORIGIN)
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_db_allrdatasets(zone->top, node, version, 0,
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington dns_rdatasetiter_current(rdsiter, &rdataset);
033ba09d6df0ac92a736a480b9c3b164b61dccb2Brian Wellington result = dns_rdataset_totext(&rdataset, name,
goto retry;
return (result);
(void)zone;
(void)tmgr;
return (DNS_R_NOTIMPLEMENTED);
return (DNS_R_UNEXPECTED);
return (DNS_R_UNEXPECTED);
return (DNS_R_UNEXPECTED);
isc_socket_t *s;
== ISC_R_SUCCESS);
s = NULL;
return (result);
isc_socket_detach(&s);
return (DNS_R_SUCCESS);
goto cleanup1;
goto cleanup2;
(void)task;
(void)event;
char *master;
goto next_master;
goto next_master;
goto next_master;
if (cnamecnt != 0) {
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
goto next_master;
#ifdef notyet
static dns_result_t
case dns_zone_master:
case dns_zone_slave:
case dns_zone_stub:
if (next == 0) {
ISC_TRUE);
return (DNS_R_UNEXPECTED);
return (DNS_R_SUCCESS);
static dns_result_t
return (result);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
return (result);
return (DNS_R_REFUSED);
return (DNS_R_REFUSED);
&rdataset);
return (DNS_R_SUCCESS);
return (DNS_R_SUCCESS);
return (DNS_R_SUCCESS);
void *uap) {
char *viewname;
&newview);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (boolean)
return (result);
isc_uint32_t i;
const char *origin;
return (result);
if (o == NULL)
return (DNS_R_NOMEMORY);
return (result);
return (result);
case dns_c_zone_master:
return (iresult);
return (iresult);
return (result);
return (result);
return (result);
return (result);
case dns_c_zone_forward:
#ifdef notyet
case dns_c_zone_slave:
return (iresult);
return (iresult);
return (result);
case dns_c_zone_stub:
return (iresult);
return (iresult);
return (result);
case dns_c_zone_hint:
return (iresult);
return (result);
return (DNS_R_SUCCESS);
acl);
acl);
acl);
int len;
len = 0;
int res = 0;
res++;
return (res);
case AF_INET:
case AF_INET6:
INSIST(0);
record_serial() {
static isc_boolean_t
return (ISC_FALSE);
goto fail;
if (dump) {
goto fail;
return (DNS_R_SUCCESS);
fail:
return (result);